function flip_image ($image, $mode
{
$width = imagesx$image);
$height = imagesy$image);
$src_x = 0;
$src_y = 0;
$src_width = $width
$src_height = $height
switch ( $mode ) {
case 'vertical': //vertical
$src_y = $height -1;
$src_height = -$height
break
case 'horizontal': //horizontal
$src_x = $width -1;
$src_width = -$width
break
case 'both': //both
$src_x = $width -1;
$src_y = $height -1;
$src_width = -$width
$src_height = -$height
break
default
return $image
}
$imgdest = imagecreatetruecolor$width, $height);
imagealphablending$imgdest, false);
imagesavealpha$imgdest, true);
if (imagecopyresampled$imgdest, $image, 0, 0, $src_x, $src_y , $width, $height, $src_width, $src_height)) {
return $imgdest
}
return $image
}