I am provided with a hosting plan with php gd version 2 and I cannot install any other library. I know image flipping can be done by using imagesx() imagesy() and imagecreatetruecolor() but they are not available in GD version 2. and I cannot upgrade to higher version. So, is there any other way to flip image horizontally and vertically using php gd version 2 or just with php? Thanks millions.
Asked
Active
Viewed 278 times
0
-
1Most likely won't help your specific case, but you can flip an image using CSS in pretty much every browser: http://css-tricks.com/snippets/css/flip-an-image/ . – Rich Bradshaw Sep 24 '12 at 14:51
-
@RichBradshaw thanks a lot but can new image flipped by CSS saved in server? I am quite new to CSS. Thanks. – ATZ Sep 25 '12 at 00:34
-
No, but sometimes that's OK, depending on what you want to do. – Rich Bradshaw Sep 25 '12 at 10:01
1 Answers
0
Maybe this will help... you will need to modify it to flip vertical though...
$size_x = imagesx($img);
$size_y = imagesy($img);
$temp = imagecreatetruecolor($size_x, $size_y);
imagecolortransparent($temp, imagecolorallocate($temp, 0, 0, 0));
imagealphablending($temp, false);
imagesavealpha($temp, true);
$x = imagecopyresampled($temp, $img, 0, 0, ($size_x-1), 0, $size_x, $size_y, 0-$size_x, $size_y);
if ($x) {
$img = $temp;
}
else {
die("Unable to flip image");
}
header("Content-type: image/gif");
imagegif($img);
imagedestroy($img);
Credit to Markus: Here is the link