Home Tutorial Php Phpgd PHP GD flip image

 
 

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

Advertisement

Related Tags for PHP GD flip image:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: November 7, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com