GD is an open source code library for the dynamic creation of images by programmers. GD is written in C, and “wrappers” are available for Perl, PHP and other languages. GD creates PNG, JPEG and GIF images, among other formats. GD is commonly used to generate charts, graphics, thumbnails, and most anything else, on the fly. While not restricted to use on the web, the most common applications of GD involve web site development.
See the GD website for more informations.
FS#209 — Certain PNG files corrupted on trivial export/import
Opened by Daniel Norton (danorton2) - Monday, 29 June 2009, 16:39 GMT+2
Last edited by Pierre Joye (Pierre) - Tuesday, 30 June 2009, 01:28 GMT+2
|
DetailsThe following PHP code corrupts a PNG image. I expect the image displayed to match the image when displayed directly from the URL. I have not been able to determine which PNG characteristics trigger the problem. I have attached a copy of the PNG. <?php
header("Content-type: image/png");
imagepng(imagecreatefrompng("http://www.w3.org/Icons/Fuzzy/b-10-structure-t.png"));
?>
Incidentally, Imagick PHP exhibits this same problem. |
b-10-structure-t.png
It is certainly a libpng issue then, which libpng version do you use?
Thanks. I have the latest stable Debian version, libpng version 1.2.27.
libpng version 1.2.37 behaves identically.
It's perfectly possible that GD and Imagick are both using the interface incorrectly.
Are you able to reproduce this with the given PNG?
Thanks.
BTW, if it makes things any easier, I have this set up for testing/demonstration at http://www.weirdmasters.net/gd/
$im = imagecreatefrompng(”http://www.w3.org/Icons/Fuzzy/b-10-structure-t.png“); imagesavealpha($im, 1); imagepng($im);
Maybe you were referring to the alpha channel to say that the result was a corrupt image.
The code I pasted here works just fine using the latest libpng. Try the windows snapshot, it uses it.
Btw, do you use php from php.net or debian? (compiled or packages)
Yes, calling imagesavealpha() is the workaround. Thanks!
IMHO, this is a bug. The flag should be set inside the image resource such as this one when the image is read.