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

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Wed Nov 22 03:42:57 EST 2006


I ran into the same issue as well a while back and it took me more than half
an hour to figure it out ....

Is it not an option to:

1) if a WMS layer is a baselayer, have it default to JPEG?
2) if a WMS layer is not a baselayer, have it default to GIF and have
transparent default to true?

That would make the most sense in my opinion conceptually, but I don't know
how difficult this would be to achieve.

Best regards,
Bart

--
Bart van den Eijnden
OSGIS, Open Source GIS
http://www.osgis.nl


--------- Oorspronkelijk bericht --------
Van: Cameron Shorter <cameron.shorter at gmail.com>
Naar: Tim Schaub <noreply at geocartic.com>
Cc: 'openlayers' <dev at openlayers.org>
Onderwerp: Re: [OpenLayers-Dev] WMS should default to GIF instead of JPG
Datum: 22/11/06 03:28

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






More information about the Dev mailing list