php5-gd imagecolorset no longer working properly after upgrade to 9.04

Bug #368036 reported by Keith Hughitt on 2009-04-27
This bug affects 1 person
Affects Status Importance Assigned to Milestone
php5 (Ubuntu)

Bug Description

Binary package hint: php5

I wrote a small piece of code using that uses the php5-gd module. The script 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. Since upgrading Ubuntu from 8.10 to 9.04, however, the script only outputs grayscale images, with no error message.

Outputting the results from 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?

I've attached some example images used in the script below, as well as the resulting image from before and after the upgrade.

$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);

Keith Hughitt (keith-hughitt) wrote :
Keith Hughitt (keith-hughitt) wrote :
Keith Hughitt (keith-hughitt) wrote :
Keith Hughitt (keith-hughitt) wrote :
Keith Hughitt (keith-hughitt) wrote :

Update: Bug also found to exist in other systems (tested Fedora 11 Beta).

Reported upstream:

Andreas Olsson (andol) wrote :

Tried your example on both a fresh Ubuntu 8.10 and a fresh Ubuntu 9.04. In both cases I actually ended up with the a grey scaled result.

Not so sure if this is an upstream issue, considering that both Ubuntu 8.10 and Ubuntu 9.04 uses the same upstream version of PHP.

Changed in php5 (Ubuntu):
status: New → Incomplete
Andreas Olsson (andol) on 2009-08-15
Changed in php5 (Ubuntu):
status: Incomplete → New
Chuck Short (zulcss) wrote :


I was wondering if you could reproducing this bug with the Karmic version.


Changed in php5 (Ubuntu):
status: New → Incomplete
Keith Hughitt (keith-hughitt) wrote :

Hi Chuck,

Thanks for following up. Actually it turns out that the issue was not really caused by a bug, but rather an increased strictness in newer versions of GD. (See upstream thread:

Overall though everything works really well in Karmic.

Ondřej Surý (ondrej) wrote :

Bug invalid per comment #8

Changed in php5 (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.