Page 1 of 1

URGENT!! Corrupt 16x16 png icon file with GD!

Posted: Wed Oct 27, 2010 11:35 pm
by blueillusion
Hey,

Having a problem with GD loading a 16x16px image and outputting to the browser, yet with other images of the same size it works fine, it's also GD version related because offline on my test server it works fine, online no.

Online server GD version: bundled (2.0.34 compatible)

Offline test server GD version: 2.0 or higher

Here's some test code I'm using, literally opens the file and outputs to the browser:

Code: Select all

header('Content-Type: image/png');
$img = imagecreatefrompng('page_white.png');
imagepng($img);
Images:
Original icon file, not corruption
Original icon file, not corruption
original-icon.png (294 Bytes) Viewed 548 times
Corrupt icon outputted to the browser
Corrupt icon outputted to the browser
corrupt-icon.png (226 Bytes) Viewed 548 times

Please could someone help out with this, would be great.. going nuts over this problem!

Re: URGENT!! Corrupt 16x16 png icon file with GD!

Posted: Thu Oct 28, 2010 10:56 am
by pickle
No idea why this is happening, but try opening up the PNG in Photoshop/Gimp and re-saving it. Maybe that'll flip whatever bit GD is chocking on.

Re: URGENT!! Corrupt 16x16 png icon file with GD!

Posted: Tue Nov 02, 2010 11:37 am
by blueillusion
pickle wrote:No idea why this is happening, but try opening up the PNG in Photoshop/Gimp and re-saving it. Maybe that'll flip whatever bit GD is chocking on.
Thanks Pickle! I'd already tried doing this ages ago; however, I opened up a good icon that works and the one that doesn't, noticed that the one that doesn't work is greyscale, and the other is RGB.. changing to RGB and saving allowed it to work online. It's strange that this is happening though!

:)

Re: URGENT!! Corrupt 16x16 png icon file with GD!

Posted: Tue Nov 02, 2010 12:00 pm
by Weirdan
That's a known issue with GD - it does not support grayscale images in its internal representation and converts them to indexed palette images:
gd2 manual wrote: If the PNG image being loaded is a truecolor image, the resulting gdImagePtr will refer to a truecolor image. If the PNG image being loaded is a palette or grayscale image, the resulting gdImagePtr will refer to a palette image.