GeoWebCache / geowebcache

GeoWebCache is a tile caching server implemented in Java that provides various tile caching services like WMS-C, TMS, WMTS, Google Maps, MS Bing and more
https://www.geowebcache.org
338 stars 281 forks source link

Transparent bit mask of 24bit PNGs is not preserved from WMS source #127

Open yakhawkes opened 12 years ago

yakhawkes commented 12 years ago

I have found that mapXtreme WMS's serve transparent PNGs not in RGBA but in RGB with a bit mask, this is not preserved when the tiles are served from GWS.

In the PNGs from the mapXtreme WMS the tRNS header block is set to #FFFFFF but when the tiles are saved and served from GWC the tRNS header block is missing meaning that the served tiles are opaque with a white background.

Here is the meta tile request to the mapXtreme WMS: http://map.kirklees.gov.uk/WMSTreePreservationOrders/GetMap.ashx?BBOX=408300.0%2C413700.0%2C408600.0%2C414000.0&TRANSPARENT=TRUE&EXCEPTIONS=application%2Fvnd.ogc.se_xml&VERSION=1.1.1&FORMAT=image%2Fpng&SERVICE=WMS&HEIGHT=750&LAYERS=KirkleesTPO&REQUEST=GetMap&STYLES=TPOComboStyle&WIDTH=750&SRS=EPSG%3A27700

and a cached title from that meta tile from GWC: http://osgb.kirklees.gov.uk/geoserver/gwc/service/wms?LAYERS=KirkleesTPO&STYLES=TPOComboStyle&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&SRS=EPSG%3A27700&BBOX=408400,413900,408500,414000&WIDTH=250&HEIGHT=250

yakhawkes commented 12 years ago

I had a look through the source and it looks like the WMSLayer properties are being created correctly as the request to the back end WMS conatins TRANSPARENT=TRUE which means that the canvas object should be of TYPE_INT_ARGB but the saved PNG is only RGB.

blocksninja commented 12 years ago

I'm having this same issue at the moment. I'm connecting to 2 different WMS servers, and both servers are serving the files as transparent images, but the GWC is serving the tiles from 1 server as non-transparent images. From the other wms-service the gwc-server is serving the images perfectly transparent.

blocksninja commented 12 years ago

I've done some more research and noticed that the files coming from the WMS-services that will give non-transparent tiles by the GWC are markes as a "8-bit/color RGB" image, where the files from a 'good' wms-service are marked as "8-bit/color RGBA". (@shawkes, I've checked your source too) So it seems that GWC is only checking between RGB and RGBA to see if the file is transparent. It should also support the transparency option in RGB: http://www.libpng.org/pub/png/book/chapter08.html#png.ch08.div.5.7

aaime commented 12 years ago

Put in other words, stand alone GWC does not seem to support paletted PNG files (8bit) with the alpha channel in the palette entries

yakhawkes commented 12 years ago

Not quite. The transparent PNGs I am having problems with are not paletted (8bit) but full colour (24bit) but instead of having an Alpha channel the PNG format sets a colour has being transparent (e.g. #FFFFFF) in the file header. It seems like when GWC sees there is no Alpha channel in a PNG it assumes that the PNG is not transparent.

aaime commented 12 years ago

On Tue, Aug 21, 2012 at 3:54 PM, shawkes notifications@github.com wrote:

Not quite. The transparent PNGs I am having problems with are not paletted (8bit) but full colour (24bit) but instead of having an Alpha channel the PNG format sets a colour has being transparent (e.g. #FFFFFF) in the file header. It seems like when GWC sees there is no Alpha channel in a PNG it assumes that the PNG is not transparent.

Ah, PNG with a transparent color, but not paletted. First time I hear of such an arrangement, it may be the Java own PNG reader does not support it, in fact a quick search around the web about Java and PNG tranparency only reports cases of usage of the alpha channel or indexed color models

Cheers Andrea

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more

information.

Ing. Andrea Aime @geowolf Technical Lead

GeoSolutions S.A.S. Via Poggio alle Viti 1187 55054 Massarosa (LU) Italy phone: +39 0584 962313 fax: +39 0584 962313 mob: +39 339 8844549

http://www.geo-solutions.it http://twitter.com/geosolutions_it