schilly Posted October 15, 2008 Share Posted October 15, 2008 I'm trying to rotate an image depending on what angle I give it. It's working but when I use it in my page it doesn't rotate. If I grab the image source link and open it up the image is rotated. I can't figure it out. test page: http://skyelights.com/maps/test_image.php Image link from that page: http://skyelights.com/maps/getDir.php?type=swell°=291 GD Source: <?php $type = $_GET['type']; $deg = $_GET['deg']; $base_dir = ''; if($type == 'swell') $default = '08.png'; else $default = '08.png'; $im = imagecreatefrompng($default); imagealphablending($im, true); // setting alpha blending on imagesavealpha($im, true); //rotate the image $white = imagecolorallocate($im, 255, 255, 255); imagecolortransparent($im, $white); $im_rotated = imagerotate($im,$deg, $white); imagealphablending($im_rotated, true); // setting alpha blending on imagesavealpha($im_rotated, true); //flip the image $size_x = imagesx($im_rotated); $size_y = imagesy($im_rotated); $temp = imagecreatetruecolor($size_x, $size_y); $white_temp = imagecolorallocate($temp, 255, 255, 255); imagefilledrectangle($temp, 0, 0, $size_x, $size_y, imagecolorallocate($temp, 255, 255, 255)); imagecolortransparent($temp, $white_temp); $x = imagecopyresampled($temp, $im_rotated, 0, 0, 0, ($size_y-1), $size_x, $size_y, $size_x, 0-$size_y); if ($x) { $im_rotated = $temp; } else { die("Unable to flip image"); } //echo $deg; // Content type header('Content-type: image/png'); imagepng($im_rotated); imagedestroy($im); imagedestroy($im_rotated); ?> Any help is appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/128544-solved-gd-image-rotation-problem/ Share on other sites More sharing options...
Barand Posted October 15, 2008 Share Posted October 15, 2008 place image on page with <img src="getDir.php?type=swell°=291"> Link to comment https://forums.phpfreaks.com/topic/128544-solved-gd-image-rotation-problem/#findComment-666309 Share on other sites More sharing options...
schilly Posted October 15, 2008 Author Share Posted October 15, 2008 hmmm weird. same thing. any ideas? Link to comment https://forums.phpfreaks.com/topic/128544-solved-gd-image-rotation-problem/#findComment-666395 Share on other sites More sharing options...
Barand Posted October 15, 2008 Share Posted October 15, 2008 When I run your code I get the image flipped vertically and rotated Link to comment https://forums.phpfreaks.com/topic/128544-solved-gd-image-rotation-problem/#findComment-666428 Share on other sites More sharing options...
schilly Posted October 15, 2008 Author Share Posted October 15, 2008 here http://skyelights.com/maps/test_image.php or http://skyelights.com/maps/getDir.php?type=swell°=291 ?? at the test_image page the arrow always shows down with safari and firefox. Link to comment https://forums.phpfreaks.com/topic/128544-solved-gd-image-rotation-problem/#findComment-666431 Share on other sites More sharing options...
Barand Posted October 15, 2008 Share Posted October 15, 2008 Only change I mage to your code was to substitute my png filename results of 0 and 270 rotations attached [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/128544-solved-gd-image-rotation-problem/#findComment-666439 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.