Last modified: 2012-02-22 12:35:17 UTC
Thumbnails of PNG images have two related problems:
* Indexed-color images are converted to true-color thumbnails, resulting in
excessive file size. Indexed-color PNGs should be converted to indexed-color
* As a result of the above, transparency in PNG thumbnails is of the variety
that causes Internet Explorer to have problems; transparency should, for now,
always be implemented in a way that will work with this browser.
Created attachment 15 [details]
Patch against 1.19 version of includes/Image.php to fix a thumbnailing bug
Created attachment 16 [details]
Cleaned up version of patch
Took out the probably accidental reversion of the last changes to Image.php;
Created attachment 17 [details]
Broken output in IE
Well, something doesn't seem to be working correctly. Here's a screen shot
(from IE6) of two images I uploaded to my test wiki -- an alpha transparency
test image [the white area should be transparent] and the english wikipedia
logo [indexed PNG with binary transparency].
First, both were turned into indexed images; the alpha test image should have
remained truecolor I think. Second, there's something _really_ weird wrong with
them. They seem to be using alpha transparency, not binary. They show ok in
Safari, but in IE6/Windows they are displayed horribly corrupt. Also, some of
the bright white spots in the wikipedia logo end up going towards transparent
instead of solid white (as visible in Safari or loaded in Gimp).
Tested with PHP 4.3.8, Mac OS X 10.3.5. Using PHP's built in libgd plus png and
jpeg libraries and ImageMagick from fink. (ImageMagick 5.5.6.
A couple other issues: this patch as is will break if ImageMagick is not
available, so it needs some tweaking to work without. Also it uses the
imagesavealpha() function which is only available from PHP 4.3.2; we're trying
to support back to 4.1.2 (what Debian ships), so check for an alternate way of
Created attachment 18 [details]
Output in IE without the patch [in GD scaling mode]
It seems that there may be some (possibly big-endian-specific) bugs in the
latest libpng package, so I tried on another machine. Linux/x86 (Fedora Core
2), PHP 5.0.1 with built-in GD. System's libpng is 1.2.5-3. The output is still
wrong: the indexed image thumb is not transparent at all, it's on a solid
background. The alpha blending test image has seemingly lost all but the red
channel, and large portions of it are mysteriously transparent in IE6/Windows
(but solid in Safari and IE 5.2/mac!)
Wow, I really do need that tylenol. ;) That last picture is with the *unpatched current code* with scaling in GD
Unfortunately, patched it produces the exact same output as it does on my Mac. Broken either way. :(
Created attachment 19 [details]
Output in IE using ImageMagick mode
Just for comparison, here's the same images rendered with current ImageMagick
scaling. IE displays the thumbs with solid white backgrounds.
My local wiki installation seems to have broken, so I can't test this right now,
but I just discovered that ImageMagick apparently has a depth-reduction option:
convert -type Palette (source) (dest)
Would it work to simply use this command, and drop all the GD stuff? i.e.:
(use the ImageMagick command we have now)
(same command, but with the -type Palette option)
Meanwhile, I'll figure out what's wrong with my wiki and test it out...
I got my local install fixed and tried this out. Seems to work OK, except there
are some odd dithering artifacts in some images; as far as I can tell,
transparency is binary (as it should be), but I don't have MSIE available to see
how well it handles them.
One option that reduces some of the speckling artifacts is "-colorspace
Transparent", which must be specified together with "-colors 255" (256 might
work but I'm assuming one index is used for transparency). Others that might
have an effect, but made no difference in my test images:
-treedepth X (where X is something other than 0 or 1)
MSDN blog entries regarding IE and PNG alpha-transparency:
Note: IE7 now supports alpha transparency in PNG images.
*** Bug 1218 has been marked as a duplicate of this bug. ***
Repurposing to the transparency issue only, leaving bug 1218 for the size increase.
Update OS/Web browser.
Adding testme. Please test with Internet Explorer 8 and note the result here.
The problem is not going to occur in Internet Explorer >= 7, since that supports alpha transparency in PNGs:
As long as IE6 still has significant market share, however, we can't just ignore it and tell users to upgrade. (Many of them are using it in locked-down corporate settings where they can't upgrade, or use another browser.)
*** Bug 12405 has been marked as a duplicate of this bug. ***
This has been around since 2004 and realistically, with IE6 at 3.5%, I don't see anyone starting to work on it now.