libGD

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.

| Tasklist |

FS#209 — Certain PNG files corrupted on trivial export/import

Attached to Project — libGD
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
Task Type Bug Report
Category Image Import/Export
Status Waiting on Customer
Assigned To No-one
Operating System Linux
Severity High
Priority Normal
Reported Version 2.0.36RC1
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 1
Private No

Details

The 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.

This task depends upon

Comment by Pierre Joye (Pierre) - Monday, 29 June 2009, 21:29 GMT+2
  • Field changed: Status (Unconfirmed → Waiting on Customer)

It is certainly a libpng issue then, which libpng version do you use?

Comment by Daniel Norton (danorton2) - Tuesday, 30 June 2009, 00:37 GMT+2

Thanks. I have the latest stable Debian version, libpng version 1.2.27.

Comment by Daniel Norton (danorton2) - Tuesday, 30 June 2009, 00:54 GMT+2

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.

Comment by Daniel Norton (danorton2) - Tuesday, 30 June 2009, 01:17 GMT+2

BTW, if it makes things any easier, I have this set up for testing/demonstration at http://www.weirdmasters.net/gd/

Comment by Pierre Joye (Pierre) - Tuesday, 30 June 2009, 01:28 GMT+2

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

Comment by Daniel Norton (danorton2) - Tuesday, 30 June 2009, 05:51 GMT+2

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.

Loading...