#48123 [Bgs]: imagecolorset() misbehaves in newer versions of PHP
ID: 48123 User updated by: vincent dot k dot hughitt at nasa dot gov Reported By: vincent dot k dot hughitt at nasa dot gov Status: Bogus Bug Type: GD related Operating System: * PHP Version: 5.2.6-3 Assigned To: pajoye New Comment: Using true grayscale images as input did the trick. Thank you for the advice pajoye. Keep up the great work! Previous Comments: [2009-05-01 12:17:23] paj...@php.net hi, There is no bug, the difference is actually a bug fix in how GD managed PNG Grayscale images. When the grayscale image has an alpha component (PNG_COLOR_TYPE_GRAY_ALPHA), a truecolor image is created. If you use a real grayscale only image the resulting image will still be a palette image. For example: http://pierre.libgd.org/48123_eit_real_grayscale.png is a grayscale only image and works as you expect. It is not a bug, however next version of GD will support grayscale images as internal formats, that will greatly ease this kind of transformation. [2009-04-30 19:37:17] vincent dot k dot hughitt at nasa dot gov Okay, got same result on Ubuntu 9.04 using compiled PHP + Bundled GD: PHP 5.2.6-3ubuntu4.1, GD bundled (2.0.34 compatible) [2009-04-30 19:12:37] j...@php.net Verified with latest CVS, using bundled GD library. [2009-04-30 18:11:51] vincent dot k dot hughitt at nasa dot gov Hi Pajoye, Thanks for the feedback. I did not know that about Ubuntu/Fedora's packaged versions of GD. I will try downloading and compiling PHP from source and see if I run into the same issues, and post my results here. If you start with the images: http://launchpadlibrarian.net/26034594/eit_grayscale.png http://launchpadlibrarian.net/26034597/ctable_eit304.png The expected output of the script is: http://launchpadlibrarian.net/26034598/eit_final_ubuntu810.jpg which is a COLOR image. The problem is that using newer version of PHP, the result is a GRAYSCALE image. [2009-04-30 17:33:11] paj...@php.net 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. The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/48123 -- Edit this bug report at http://bugs.php.net/?id=48123&edit=1
#48123 [Asn]: imagecolorset no longer behaving properly in newer versions of PHP
ID: 48123 User updated by: vincent dot k dot hughitt at nasa dot gov Reported By: vincent dot k dot hughitt at nasa dot gov Status: Assigned Bug Type: GD related Operating System: * -PHP Version: 5.*, 6CVS (2009-04-30) +PHP Version: 5.2.6-3 Assigned To: pajoye New Comment: Okay, got same result on Ubuntu 9.04 using compiled PHP + Bundled GD: PHP 5.2.6-3ubuntu4.1, GD bundled (2.0.34 compatible) Previous Comments: [2009-04-30 19:12:37] j...@php.net Verified with latest CVS, using bundled GD library. [2009-04-30 18:11:51] vincent dot k dot hughitt at nasa dot gov Hi Pajoye, Thanks for the feedback. I did not know that about Ubuntu/Fedora's packaged versions of GD. I will try downloading and compiling PHP from source and see if I run into the same issues, and post my results here. If you start with the images: http://launchpadlibrarian.net/26034594/eit_grayscale.png http://launchpadlibrarian.net/26034597/ctable_eit304.png The expected output of the script is: http://launchpadlibrarian.net/26034598/eit_final_ubuntu810.jpg which is a COLOR image. The problem is that using newer version of PHP, the result is a GRAYSCALE image. [2009-04-30 17:33:11] paj...@php.net 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. [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
#48123 [Fbk->Opn]: imagecolorset no longer behaving properly in newer versions of PHP
ID: 48123 User updated by: vincent dot k dot hughitt at nasa dot gov Reported By: vincent dot k dot hughitt at nasa dot gov -Status: Feedback +Status: Open Bug Type: GD related Operating System: Ubuntu 9.04, Fedora 11 PHP Version: 5.2.9 New Comment: Hi Pajoye, Thanks for the feedback. I did not know that about Ubuntu/Fedora's packaged versions of GD. I will try downloading and compiling PHP from source and see if I run into the same issues, and post my results here. If you start with the images: http://launchpadlibrarian.net/26034594/eit_grayscale.png http://launchpadlibrarian.net/26034597/ctable_eit304.png The expected output of the script is: http://launchpadlibrarian.net/26034598/eit_final_ubuntu810.jpg which is a COLOR image. The problem is that using newer version of PHP, the result is a GRAYSCALE image. Previous Comments: [2009-04-30 17:33:11] paj...@php.net 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. [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
#48123 [NEW]: imagecolorset no longer behaving properly in newer versions of PHP
From: vincent dot k dot hughitt at nasa dot gov Operating system: Ubuntu 9.04, Fedora 11 PHP version: 5.2.9 PHP Bug Type: GD related Bug description: imagecolorset no longer behaving properly in newer versions of PHP 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 bug report at http://bugs.php.net/?id=48123&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48123&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48123&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48123&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48123&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48123&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48123&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48123&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48123&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48123&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48123&r=support Expected behavior: http://bugs.php.net/fix.php?id=48123&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48123&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48123&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48123&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48123&r=php4 Daylight Savings:http://bugs.php.net/fix.php?id=48123&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48123&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48123&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48123&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48123&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48123&r=mysqlcfg