Opened 19 years ago

Last modified 19 years ago

#1089 new enhancement

png alpha problems in Internet Explorer

Reported by: bartvde@… Owned by: mapserverbugs
Priority: high Milestone: FUTURE
Component: MapScript-PHP Version: 4.4
Severity: minor Keywords:
Cc: sgillies@…

Description

The fix to bug 425 has side-effects for the way PNG24 images generated by
Mapscript are displayed with Internet Explorer (they have a grey background now).

The alpha channel is rendered correctly, unfortunately against the color taken
from bKGD chunk.

Browser examples: Microsoft Internet Explorer up to 6.0, Netscape up to 4.8,
Amaya 2.4.

The following could be a fix for IE, but I have no idea how easy this is ...

Include bKGD chunk in the image, and set the color to “expected average
background color under the image”. This way you have at least some control over
it and are not at the mercy of browsers' random decisions about the background
color. 

http://www.libpng.org/pub/png/spec/1.2/PNG-Chunks.html#C.bKGD

Change History (15)

comment:1 by bartvde@…, 19 years ago

dependson: 425

comment:2 by sgillies@…, 19 years ago

Cc: sgillies@… added

comment:3 by dmorissette, 19 years ago

Cc: warmerdam@… added
Maybe Frank would have some idea on that?

comment:4 by fwarmerdam, 19 years ago

Bart, 

You mentioned in bug 425 that "This has side-effects for the way PNG24 images
generated by Mapscript are displayed with Internet Explorer (they have a grey
background now)."  Is this a change from previous behavior of mapserver generated
PNG24 images?  

If we were to try and produce kKBD chunks from MapServer what background value
would we use?  Should we set it to the background color in the .map file's
IMAGECOLOR setting?

Note that to get a particular chunk produced in the png file, it would 
likely be necessary to hack on GD, not MapServer itself.  I'm not sure it would
be practical for us to maintain such a change, though we could potentially keep 
a patch file around that people could apply themselves.  Alternatively, I could
extend the GDAL/PNG driver to support the needs, and then it could be 
controlled via an outputformat formatoption setting. 

All in all though, I suspect I am missing something with regard to how
things used to work.  

comment:5 by bartvde@…, 19 years ago

Hi Frank,

with php_mapscript_44 beta2 the images are not displayed grey in IE, but with 4.
4 beta 2 (and before) the alpha channel was not present if I understand 
correctly (that was the subject of bug 425).

See e.g. in IE (if you have it installed):
http://www.vz.geodan.nl:1111/cgi-bin/44beta3/mapserv.exe?map=/ms4w/apps/
geoservices/map/geoservices.map&version=1.1.1&request=GetMap&bbox=100000,300000,
200000,400000&width=500&height=500&layers=Gemeentes&srs=EPSG:28992

But this was already a problem with 4.2 (mapserv.exe), but for mapscript this 
behaviour was introduced in 4.4beta3, and that is the core of images output by 
Chameleon.

comment:6 by dmorissette, 19 years ago

With respect to PHP MapScript, bug 425 prevented it from producing transparent
PNG's completely... so unless Bart modified his scripts, he probably always had
opaque PNGs before, that would be why the transparency issue just came up today.

Please prove me wrong Bart.  ;)

comment:7 by bartvde@…, 19 years ago

You are absolutely right Daniel :)

comment:8 by dmorissette, 19 years ago

So does this becomes a non-issue since you should simply turn off the
transparent flag to continue to get opaque images as you used to?

comment:9 by bartvde@…, 19 years ago

Daniel, using the following output format definition the problem in IE still
remains:

  OUTPUTFORMAT
    NAME png
    MIMETYPE image/png
    DRIVER GD/PNG
    EXTENSION png
    IMAGEMODE RGBA
    TRANSPARENT FALSE
  END

comment:10 by fwarmerdam, 19 years ago

Bart, please use IMAGEMODE RGB not IMAGEMODE RGBA if you want non-transparent 
images.  Could you try that and verify?

comment:11 by bartvde@…, 19 years ago

Frank, I checked, same problem still exists.

  OUTPUTFORMAT
    NAME png
    MIMETYPE image/png
    DRIVER GD/PNG
    EXTENSION png
    IMAGEMODE RGB
    TRANSPARENT FALSE
  END

comment:12 by fwarmerdam, 19 years ago

Bart, 

Could you:

1) send me the png from the transparent=no, imagemode=rgb case. 

2) explain what behavior you see in ie that is undesirable. 

3) explain what behaviour you want/expect.

I am having a hard time seeing what could be going wrong, but it might be
that something is badly broken in the 24bit png handling. 

comment:13 by bartvde@…, 19 years ago

I have done a few tests using tweakpng (http://entropymine.com/jason/tweakpng/).

The images returned by mapserver don't have the bKGD chunk set, and the default
in IE is grey. If I set the bKGD chunck to white using tweakpng, it works as I
would expect in IE.

See:
http://www.vz.geodan.nl:1111/geoservices/test.html

comment:14 by bartvde@…, 19 years ago

Unfortunately GD does not support this at the moment:

Currently there is no way to set the bKGD chunk from gd. This is something
we'll have to look at for a future gd update.
 
--
Thomas Boutell
Boutell.Com, Inc. http://www.boutell.com/

comment:15 by bartvde@…, 19 years ago

Milestone: FUTURE
Severity: normalenhancement
Changing to enhancement (will require changes in GD as well), and setting target
to future.
Note: See TracTickets for help on using tickets.