Page MenuHomePhabricator

PNG thumbnails change binary transparency to alpha transparency, causing IE6 problems
Closed, DeclinedPublic

Assigned To
Authored By
Aug 27 2004, 5:21 PM
Referenced Files
F1229: Alpha_in_IE_ImageMagick.png
Nov 21 2014, 6:45 PM
F1228: Alpha_in_IE_again.png
Nov 21 2014, 6:45 PM
F1227: Alpha_in_IE.png
Nov 21 2014, 6:45 PM
F1226: ThumbnailPatch3.diff
Nov 21 2014, 6:45 PM
F1225: ThumbnailPatch.diff
Nov 21 2014, 6:45 PM


Author: wapcaplet99

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.

Version: unspecified
Severity: minor
OS: Windows XP



Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 6:45 PM
bzimport set Reference to bz234.
bzimport added a subscriber: Unknown Object (MLST).

wapcaplet99 wrote:

Patch against 1.19 version of includes/Image.php to fix a thumbnailing bug


Created attachment 16
Cleaned up version of patch

Took out the probably accidental reversion of the last changes to Image.php;
fixed spacing.


Created attachment 17
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
doing this.


Alpha_in_IE.png (437×508 px, 50 KB)

Created attachment 18
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!)

Argggh... tylenol...


Alpha_in_IE_again.png (437×518 px, 62 KB)

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


Alpha_in_IE_ImageMagick.png (441×396 px, 72 KB)

wapcaplet99 wrote:

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

if truecolor
(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...

wapcaplet99 wrote:

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)
-quality X

ayg wrote:

*** Bug 1218 has been marked as a duplicate of this bug. ***

ayg wrote:

Repurposing to the transparency issue only, leaving bug 1218 for the size increase.

Adding testme. Please test with Internet Explorer 8 and note the result here.

ayg wrote:

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.

Restricted Application added a subscriber: Matanya. · View Herald Transcript