This example shows how to display and flip image in php gd.
This example shows how to display and flip image in php gd.<?php
$image = imagecreatefromjpeg("images.jpg");
$image = flip($image,1,1);
header("Content-type: image/jpeg");
imagejpeg($image);
imagedestroy($image);
function flip($i,$h=1,$v=0) {
$width = imagesx($i);
$height = imagesy($i);
$temp = imagecreatetruecolor($width,$height);
imagecopy($temp,$i,0,0,0,0,$width,$height);
if ($h==1) {
for ($x=0 ; $x<$width ; $x++) {
imagecopy($i, $temp, $width-$x-1, 0, $x, 0, 1, $height);
}
imagecopy($temp,$i,0,0,0,0,$width,$height);
}
if($v==1) {
for ($x=0; $x<$height ; $x++) {
imagecopy($i, $temp, 0, $height-$x-1, 0, $x, $width, 1);
}
}
return $i;
}
?>
After running the program you will get the following output