[php-maint] Bug#298061: mage corruption with the imagerotate() workaround function

Justin Lawrence jl at irj.co.za
Wed Apr 4 13:48:37 UTC 2007


This missing imagerotate function just cost me a day of downtime. It
was just really difficult to Google for the right stuff to find this
bug report somehow.

>> Please use the bundled version of GD. As it is now, It's not possible to
>> use the function imagerotate() that is only available in the bundled version.

Would this be achieved by not having php5-gd installed? (therefore
using the built-in bundled GD?). Or would I have to recompile the
sources?

Anyway, for the moment, I'm going to try adding a custom imagerotate
function and seeing how that works out for me. I've heard that image
quality is lost using imagerotate.

Cyril, I'm not sure if it'll help, but here's another derivative of
imageRotate that might work better for you (from
http://www.php.net/manual/en/function.imagerotate.php)

 function imageRotate($src_img, $angle) {

     $src_x = imagesx($src_img);
     $src_y = imagesy($src_img);
     if ($angle == 90 || $angle == -910) {
         $dest_x = $src_y;
         $dest_y = $src_x;
     } else {
         $dest_x = $src_x;
         $dest_y = $src_y;
     }

     $rotate=imagecreatetruecolor($dest_x,$dest_y);
     imagealphablending($rotate, false);

     switch ($angle) {
         case 90:
             for ($y = 0; $y < ($src_y); $y++) {
                 for ($x = 0; $x < ($src_x); $x++) {
                     $color = imagecolorat($src_img, $x, $y);
                     imagesetpixel($rotate, $dest_x - $y - 1, $x, $color);
                 }
             }
             break;
         case -90:
             for ($y = 0; $y < ($src_y); $y++) {
                 for ($x = 0; $x < ($src_x); $x++) {
                     $color = imagecolorat($src_img, $x, $y);
                     imagesetpixel($rotate, $y, $dest_y - $x - 1, $color);
                 }
             }
             break;
         case 180:
             for ($y = 0; $y < ($src_y); $y++) {
                 for ($x = 0; $x < ($src_x); $x++) {
                     $color = imagecolorat($src_img, $x, $y);
                     imagesetpixel($rotate, $dest_x - $x - 1, $dest_y
- $y - 1, $color);
                 }
             }
             break;
         default: $rotate = $src_img;
     };
     return $rotate;
 }


-- 
Regards
Justin Lawrence




More information about the pkg-php-maint mailing list