php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28341 ImagePNG transparency broken on truecolor images
Submitted: 2004-05-10 01:44 UTC Modified: 2004-05-10 04:25 UTC
From: info at silisoftware dot com Assigned:
Status: Not a bug Package: GD related
PHP Version: 4.3.6 OS: Windows XP Pro
Private report: No CVE-ID:
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
27 + 14 = ?
Subscribe to this entry?

 
 [2004-05-10 01:44 UTC] info at silisoftware dot com
Description:
------------
ImagePNG does not output transparent PNG images when in true-color mode, but does when in paletted mode. Before this gets thrown in the bogus pile as a browser issue - it's not - please download both these files and open them in Photoshop and see whether or not the transparency is recognized.

This issues was previously addressed (http://bugs.php.net/bug.php?id=22323) but appears to be re-broken and still not fixed in the latest version (4.3.6)

Reproduce code:
---------------
$Image = ImageCreateTrueColor(80,40);

$back  = ImageColorAllocate($Image,255,255,  0);
$red   = ImageColorAllocate($Image,255,  0,  0);
$green = ImageColorAllocate($Image,  0,255,  0);
$black = ImageColorAllocate($Image,  0,  0,  0);

ImageColorTransparent($Image, $back);
ImageFilledRectangle($Image,0,0,80,40,$back);
ImageArc($Image,20,20,32,32,120,0, $red);
ImageString($Image,5,20,20, 'hello', $black);

//ImageTrueColorToPalette($Image, true, 256);
ImagePNG($Image, 'c:/bad.png');


Expected result:
----------------
I expect this:
http://www.silisoftware.com/temp/imagepng-transparency/good.png

A red arc, black text on a transparent background. And I do get this if I use the commented-out line above to convert the true color image to a paletted image.

Actual result:
--------------
I get this:
http://www.silisoftware.com/temp/imagepng-transparency/good.png

A red arc, black text on a yellow (non-transparent) background.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-05-10 01:46 UTC] info at silisoftware dot com
Correction on the URLs:

Expected Result:
http://www.silisoftware.com/temp/imagepng-transparency/good.png

Actual Result:
http://www.silisoftware.com/temp/imagepng-transparency/bad.png
 [2004-05-10 02:25 UTC] magnus@php.net
Works fine here.

If you're using IE, change to a browser with a working png implementation such as Mozilla Firefox.
 [2004-05-10 02:33 UTC] info at silisoftware dot com
I'm not talking browser issues (as I said at the top of my bug report). Please download the said images (or generate them yourself) and open them with an image editor such as Photoshop and tell me whether or not both images open with transparent backgrounds.
 [2004-05-10 03:46 UTC] magnus@php.net
There's nothing wrong with either of them. Both works fine here with Mozilla Firefox, gqview, gimp-2.0-pre and Konqueror all compiled against libpng 1.2.5.
 [2004-05-10 04:25 UTC] info at silisoftware dot com
Interesting. After a little more testing on available Windows software:

Both images have transparency in:
ImageMagick IMDisplay 1.0, Mozilla 1.6, Opera 7.23

"good" works, "bad" doesn't in:
IE 6, Adobe Photoshop 7, Adobe ImageReady 7, Paint Shop Pro 7

I'm not surprised that IE is broken, but I am surprised that the graphics programs are all broken like that. I'm not sure who to pin the blame on - encoding or decoding (I'm sure you'll leave this as bogus and blame the decoders though ;)
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Mon Aug 21 08:01:40 2017 UTC