Mapserver GIF Transparency

Argggghhhh. Driving me up the wall.

If anyone has been able to get gif transparency working on mapserver please drop me a line. I have tweaked, toggled and modified

  • the outputformat. Hell I even tried the slower gdal gif renderer (instead of GD)
  • LAYER level transparency of alpha/0/100/1000 (all various suggestions on list)
  • MAP level transparent ON
  • MAP level IMAGECOLOR 255 255 255
  • setting TRANSPARENT=true in the request
  • playing around the BGCOLOR KVP in the request

This is all on a very simple style of

CLASS
STYLE
OUTLINECOLOR 255 0 0
END
END

Google Earth does support transparency, and i am sure the problem is with mapserver (the gifs definately aren’t transparent). Some mention of similar problems are in this thread but alas, no solution. ArcIMS and Geoserver are a snap to setup transparency … another story with mapserver

Hopefully someone out there knows – otherwise its back to the list

trans

6 thoughts on “Mapserver GIF Transparency”

  1. Hi Chris,

    I have set up a WMS with MapServer and am now trying to view the layers with Google Earth and I have come up against a similar problem to you. I am serving satellite imagery of sea-surface temperature (raster files) with transparent land and I can view that just fine with Google Earth – the Google land shows through. I am also serving up some overlays – coastline, continental shelf edge and fish sample locations. The data for these are ESRI shape files and I cannot get Google Earth to render the background as transparent.

    If you send me an email I can send you the map file and KML file if you are interested.

    If you have solved the transparency problem, I would love to hear about it.

    Regards,

    Paul (Hobart, Tasmania)

  2. Hey paul,

    I did solve this using PNG and from memory it was turning off interlacing in the OUTPUTFORMAT for image/png

    Flick me a mail if you havent heard from me tomorrow with the relevant mapfile excerpts

  3. Hi Chris,

    I only have a problem with (non)transparent background, when GoogleEarth requests data from my Mapserver where there is no data to see.

    Disregarding all TRANSAPRENT settings it just floods the earth with the set IMAGECOLOR.

    In cases where GE requests a part with actual Mapserver coverage all is good (inculding transparency)

    Any clues?

    (another) Chris, Brazil

  4. Ok, never mind… Using PNG for the RIGHT WMS request magically worked…

    Funny how stuff works when you do it right, isn’t it?

    Thanks for the hint!

  5. Chris,

    Thanks for the tips. I have followed your advice and now my overlays have transparent backgrounds as planned. I can confirm that you do need to turn off interlace for the PNG images.

    One quirk that I found – I asked for one of my layers to be black (0 0 0) and the background for this was not transparent. I changed the colour to (1 1 1) and the background was transparent.

    It would be nice to know why transparency works for PNG images but not for GIF images but at least I can continue with my work.

    Thanks again for your help.

    Paul.

  6. For gifs, you need to use this in your .map file:

    OUTPUTFORMAT
    NAME gif
    DRIVER “GD/GIF”
    MIMETYPE “image/gif”
    IMAGEMODE PC256
    EXTENSION “gif”
    TRANSPARENT ON
    END

    by default, transparent is NOT on.

Comments are closed.