[OpenLayers-Dev] WMS should default to GIF instead of JPG

Cameron Shorter cameron.shorter at gmail.com
Wed Nov 22 00:27:13 EST 2006


I should add,
What triggered this suggestion is a query on the IRC:

"I've set transparent=TRUE, but the WMS layers are still not 
transparent. Why?"

I knew the answer because I had been stuck on the same problem. The 
images were defaulting to JPG instead of GIF.

Tim Schaub wrote:
>>For WMS layers, which are usually placed over a photo basemap 
>>like GoogleMaps?, GIF is a better format. GIF is lossless and 
>>works best for images with a fixed number of colors (as is 
>>usually returned by WMS layers). GIF allows transparency.
> 
> 
> I don't know if it's true that WMS layers are used as overlays more often
> than basemaps.
> 
> To get a WMS layer to behave as an overlay, you have to send it either the
> isBaseLayer:false option or the transparent:'true' parameter.  As long as
> you're constructing your WMS overlay with one of these, it doesn't seem like
> too much of a hassle to add format: 'image/gif' or format:'image/png' and
> transparent:'true'.
> 
> 
>>And for the record, PNG has similar properties to GIF, but 
>>older versions of IE have problems rendering PNG layers, so 
>>is not a suggested format.
> 
> 
> Actually, regular old transparency in PNG is supported in the most common IE
> setup (IE6 on Windows).  It is alpha transparency in 24 bit PNG that is a
> headache in pre-IE7 (this is for partially transparent pixels instead of a
> single color indexed as transparent).
> 
> Also, not all WMS servers will give you a GIF with transparency just by
> asking for GIF.  Compare these two images (first one GIF without a
> transparent background, second one PNG that does give you transparency).
> 
> (GIF that doesn't have a transparent background)
> http://maps.customweather.com/image?LAYERS=earthquakes&FORMAT=image%2Fgif&TR
> ANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=a
> pplication%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-180%2C-90%2C180%2C270&
> WIDTH=256&HEIGHT=256
> 
> (PNG that does have a transparent background)
> http://maps.customweather.com/image?LAYERS=earthquakes&FORMAT=image%2Fpng&TR
> ANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=a
> pplication%2Fvnd.ogc.se_inimage&SRS=EPSG%3A4326&BBOX=-180%2C-90%2C180%2C270&
> WIDTH=256&HEIGHT=256
> 
> Note that this site is serving up PNG with alpha transparency (32 bit), so
> this is a problem for IE.  The point is that just because you ask for a GIF,
> you may not get a transparent background.
> 
> 
>>So I suggest that the default format offered by the 
>>Openlayers WMS is GIF format instead of JPG as is currently the case.
> 
> 
> Whether GIF or JPEG is the default doesn't make much difference to me.
> Since transparent is not 'true' by default (in the WMS.js parameters), I
> think your best off if you're explicit about asking for what you want.
> 
> Tim
> 
> 
>>--
>>Cameron Shorter
>>http://cameron.shorter.net
>>_______________________________________________
>>Dev mailing list
>>Dev at openlayers.org
>>http://openlayers.org/mailman/listinfo/dev
>>
> 
> 
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
> 


-- 
Cameron Shorter
http://cameron.shorter.net



More information about the Dev mailing list