Home Tutorial Php Phpgd PHP GD flip image

 
 

PHP GD flip image
Posted on: November 7, 2009 at 12:00 AM
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

Related Tags for PHP GD flip image:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.