MapServer / MapServer-import

3 stars 2 forks source link

png alpha problems in Internet Explorer #1089

Open tbonfort opened 12 years ago

tbonfort commented 12 years ago

Reporter: bartvde@osgis.nl Date: 2004/11/24 - 20:44

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
tbonfort commented 12 years ago

Author: dmorissette Date: 2004/11/24 - 23:49

Maybe Frank would have some idea on that?
tbonfort commented 12 years ago

Author: fwarmerdam Date: 2004/11/25 - 21:31

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.  
tbonfort commented 12 years ago

Author: bartvde@osgis.nl Date: 2004/11/25 - 21:46

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.
tbonfort commented 12 years ago

Author: dmorissette Date: 2004/11/25 - 21:50

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.  ;)
tbonfort commented 12 years ago

Author: bartvde@osgis.nl Date: 2004/11/26 - 07:42

You are absolutely right Daniel :)
tbonfort commented 12 years ago

Author: dmorissette Date: 2004/11/26 - 20:58

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?
tbonfort commented 12 years ago

Author: bartvde@osgis.nl Date: 2004/11/27 - 15:58

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
tbonfort commented 12 years ago

Author: fwarmerdam Date: 2004/11/27 - 17:02

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

Author: bartvde@osgis.nl Date: 2004/11/27 - 17:18

Frank, I checked, same problem still exists.

  OUTPUTFORMAT
    NAME png
    MIMETYPE image/png
    DRIVER GD/PNG
    EXTENSION png
    IMAGEMODE RGB
    TRANSPARENT FALSE
  END
tbonfort commented 12 years ago

Author: fwarmerdam Date: 2004/11/27 - 17:40

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. 
tbonfort commented 12 years ago

Author: bartvde@osgis.nl Date: 2004/11/30 - 17:16

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
tbonfort commented 12 years ago

Author: bartvde@osgis.nl Date: 2004/11/30 - 17:25

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/
tbonfort commented 12 years ago

Author: bartvde@osgis.nl Date: 2005/05/11 - 21:37

Changing to enhancement (will require changes in GD as well), and setting target
to future.