[Geoserver-users] How to get TRANSPARENT PNG image from GeoServer?

Hi,

Works for me with Geoserver 2.8 and these requests:

Transparent with this gdalinfo report

Band 1 Block=768x1 Type=Byte, ColorInterp=Red

Mask Flags: PER_DATASET ALPHA

Band 2 Block=768x1 Type=Byte, ColorInterp=Green

Mask Flags: PER_DATASET ALPHA

Band 3 Block=768x1 Type=Byte, ColorInterp=Blue

Mask Flags: PER_DATASET ALPHA

Band 4 Block=768x1 Type=Byte, ColorInterp=Alpha

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=768&height=537&srs=EPSG:26713&format=image/png&transparent=true

Non-transparent with gdalinfo report

Band 1 Block=768x1 Type=Byte, ColorInterp=Red

Band 2 Block=768x1 Type=Byte, ColorInterp=Green

Band 3 Block=768x1 Type=Byte, ColorInterp=Blue

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=768&height=537&srs=EPSG:26713&format=image/png

This setting makes the map transparent from where there are no vector features. I wonder if your problems is that your polygons are covering the labels from the other layer? Then you must change the rendering order.

-Jukka Rahkonen-

KhunSanAung wrote:

···

Hi All,

I’m using WMS Request to get PNG images from GeoServer.

I’m fusing two different PNG layers (One for Features & One for Labels) outside of GeoServer.

I found that both of my PNG files are not transparent for overlaying each other.

I’ve added &TRANSPARENT=TRUE
But it doesn’t work as I supposed.

Can anybody help me How can I make WMS request to GeoServer to get TRANSPARENT Image?

Thank you very much in advanced.


sample WMS Request is as below.


http://localhost:8080/geoserver/Myanmar/wms?LAYERS=Myanmar%3Atownship_area&STYLES=&FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A32647&BBOX=40547.642456059,1791371.3200072,276491.62298584,2318896.7262572&WIDTH=229&HEIGHT=512

Have a nice day!

Mr. Khun San Aung

.. also, the WMS spec has some things to say about combinations of the FORMAT-, BGCOLOR- and TRANSPARENT-parameters, which always seem to surprise me, and I always need to look up when I need it.

Regards,
/julian
________________________________________
Fra: Rahkonen Jukka (MML) [jukka.rahkonen@anonymised.com]
Sendt: 30. november 2015 09:58
Til: KhunSanAung.GIS@anonymised.com; geoserver-users@lists.sourceforge.net
Emne: Re: [Geoserver-users] How to get TRANSPARENT PNG image from GeoServer?

Hi,

Works for me with Geoserver 2.8 and these requests:

Transparent with this gdalinfo report
Band 1 Block=768x1 Type=Byte, ColorInterp=Red
  Mask Flags: PER_DATASET ALPHA
Band 2 Block=768x1 Type=Byte, ColorInterp=Green
  Mask Flags: PER_DATASET ALPHA
Band 3 Block=768x1 Type=Byte, ColorInterp=Blue
  Mask Flags: PER_DATASET ALPHA
Band 4 Block=768x1 Type=Byte, ColorInterp=Alpha

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=768&height=537&srs=EPSG:26713&format=image/png&transparent=true
Non-transparent with gdalinfo report
Band 1 Block=768x1 Type=Byte, ColorInterp=Red
Band 2 Block=768x1 Type=Byte, ColorInterp=Green
Band 3 Block=768x1 Type=Byte, ColorInterp=Blue

http://localhost:8080/geoserver/sf/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=768&height=537&srs=EPSG:26713&format=image/png
This setting makes the map transparent from where there are no vector features. I wonder if your problems is that your polygons are covering the labels from the other layer? Then you must change the rendering order.

-Jukka Rahkonen-

KhunSanAung wrote:

Hi All,

I'm using WMS Request to get PNG images from GeoServer.
I'm fusing two different PNG layers (One for Features & One for Labels) outside of GeoServer.

I found that both of my PNG files are not transparent for overlaying each other.

I've added &TRANSPARENT=TRUE
But it doesn't work as I supposed.

Can anybody help me How can I make WMS request to GeoServer to get TRANSPARENT Image?

Thank you very much in advanced.
---
sample WMS Request is as below.
-----
http://localhost:8080/geoserver/Myanmar/wms?LAYERS=Myanmar%3Atownship_area&STYLES=&FORMAT=image%2Fpng&TRANSPARENT=TRUE&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A32647&BBOX=40547.642456059,1791371.3200072,276491.62298584,2318896.7262572&WIDTH=229&HEIGHT=512

--
Have a nice day!
--

Mr. Khun San Aung