ID: 48123 Updated by: paj...@php.net Reported By: vincent dot k dot hughitt at nasa dot gov -Status: Open +Status: Feedback Bug Type: GD related Operating System: Ubuntu 9.04, Fedora 11 PHP Version: 5.2.9 New Comment:
and what do you expect as "correct" result? for this script. And please not that both Debian and Ubuntu do not use the bundled GD as it is recommended and the GD version they use is in a poor state (ubuntu being less worst). Please try the same using a normal php too, compiling it with the bundled GD. Previous Comments: ------------------------------------------------------------------------ [2009-04-30 16:46:10] vincent dot k dot hughitt at nasa dot gov Description: ------------ I wrote a small piece of code using that uses the GD module to apply a color-table to a gray-scale image. In newer versions of PHP, however, the script only outputs grayscale images, with no error message. Furthermore, outputting the contents of imagecolorsforindex shows that the script is still reading the palette properly, so it must have something to do with the next step (imagecolorset). Any ideas? =========================================================== System 1 (non-working): Ubuntu 9.04 Linux 2.6.28-11-generic PHP 5.2.6-3ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Apr 23 2009 14:35:05) gd 2.0.36~rc1~dfsg-3ubuntu1 =========================================================== System 2 (non-working): Fedora 11 Beta Linux 2.6.29.1-111.fc11.i586 PHP 5.2.9 gd 2.0.35 =========================================================== System 3 (WORKING): Ubuntu 8.10 Linux 2.6.27-11-generic PHP 5.2.6-2ubuntu4.1 with Suhosin-Patch 0.9.6.2 (cli) (built: Feb 11 2009 20:38:24) gd 2.0.36~rc1~dfsg-3ubuntu1 =========================================================== (Originally reported downstream at: https://bugs.edge.launchpad.net/ubuntu/+source/php5/+bug/368036) Reproduce code: --------------- /** * Takes a grayscale PNG and modifies it's index to use 256-color * lookup table then outputs it as an 8-bit JPEG image, or 8-bit * paletted PNG. * * Sample image and color-table: * * http://launchpadlibrarian.net/26034594/eit_grayscale.png * http://launchpadlibrarian.net/26034597/ctable_eit304.png */ $gd = imagecreatefrompng("eit_grayscale.png"); $ctable = imagecreatefrompng("ctable_eit304.png"); for ($i = 0; $i <= 255; $i++) { $rgba = imagecolorsforindex($ctable, $i); imagecolorset($gd, $i, $rgba["red"], $rgba["green"], $rgba["blue"]); } imagejpeg($gd, "eit_final.jpg", 75); imagedestroy($gd); imagedestroy($ctable); Expected result: ---------------- Outputs a 8-bit color JPEG. (http://launchpadlibrarian.net/26034598/eit_final_ubuntu810.jpg) Actual result: -------------- Outputs a 8-bit grayscale JPEG. (http://launchpadlibrarian.net/26034602/eit_final_ubuntu904.jpg) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48123&edit=1