[mapserver-users] 8 bit versus 24 bit output in MapServer 6.x

Stephen Woodbridge woodbri at swoodbridge.com
Tue Oct 23 21:15:08 PDT 2012


On 10/23/2012 11:30 PM, Richard Greenwood wrote:
> On Tue, Oct 23, 2012 at 9:24 PM, Richard Greenwood
> <richard.greenwood at gmail.com> wrote:
>> On Tue, Oct 23, 2012 at 7:30 PM, Stephen Woodbridge
>> <woodbri at swoodbridge.com> wrote:
>>> On 10/23/2012 4:31 PM, Richard Greenwood wrote:
>>>>
>>>> All -
>>>>
>>>> I've have always used 8 bit GIFs because they are generally the
>>>> smallest. I serve a rural area with flaky internet and I do a good bit
>>>> with mobile, so size is more important to me than pixel-perfect.
>>>> Since MapServer 6.0 I have found 8 bit output (GIF or PNG) to be much
>>>> more buggy than 24 bit output. Bugs that I have been able to isolate
>>>> and report have been fixed very quickly by the devs, but I'm
>>>> struggling with a couple now that are sporadic and that I can not
>>>> shrink down to a reproducible bug report. I see the same issues in
>>>> Windows and Linux. I'm running 6.0.3 on both. So:
>>>> 1. What image format are people generally using? Am I stuck in the
>>>> past with 8 bit images? Should I just go with 24 bit and not worry
>>>> that my images are several times larger?
>>>> 2. My general sense is that the root of the issues I'm seeing are in
>>>> the shift from GD to AGG. Are PC256 PNGs generated by GD or AGG?
>>>> 3. Any general advise for 8 bit output? For GIF is use the default (I
>>>> don't define an OUTPUTFORMAT block) for PNG I do define an
>>>> OUTPUTFORMAT block and use IMAGEMODE PC256.
>>>>
>>>> The two issues that I'm struggling with right now are that my label
>>>> colors change as I pan and zoom, and that the HATCH fill pattern
>>>> extends outside of its polygons. In both cases switching from an 8 bit
>>>> output to a 24 bit output resolves the issue.
>>>>
>>>> Thanks,
>>>> Rich
>>>>
>>>
>>> Rich,
>>>
>>> I use this:
>>>
>>>      OUTPUTFORMAT
>>>          NAME "agg_qn"
>>>          DRIVER "AGG/PNG"
>>>          EXTENSION "png"
>>>          MIMETYPE "image/png"
>>>          IMAGEMODE RGB
>>>          FORMATOPTION "INTERLACE=false"
>>>          FORMATOPTION "QUANTIZE_NEW=ON"
>>>          FORMATOPTION "QUANTIZE_FORCE=ON"
>>>          FORMATOPTION "QUANTIZE_DITHER=OFF"
>>>          FORMATOPTION "QUANTIZE_COLORS=256"
>>>          #TRANSPARENT ON
>>>          #FORMATOPTION "TRANSPARENT=ON"
>>>      END
>>>
>>> It gives me 8-bit png and I have no problem with it. Here is an example
>>> using mapserver and mapcache
>>>
>>> http://imaptools.com:8080/demo/tiger-tiles.html
>>>
>>> And here is an example using just mapserver and draw on demand:
>>>
>>> http://imaptools.com:8080/demo/tiger2011.html
>>>
>>> I think both of these are using:
>>>
>>> MapServer version 6.0.2 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG SUPPORTS=PROJ
>>> SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV SUPPORTS=FRIBIDI
>>> SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=GEOS
>>> INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE
>>>
>>> Hope this helps,
>>>    -Steve W
>>
>> Thanks Steve. That's an improvement. The image is still much larger
>> than the default GIF, or PNG with IMAGEMODE PC256, but it does
>> eliminate at least one of my sporadic bugs.
>>
>> I've attached two PNGs:
>> 1. rgb-good.png is 67K and uses your suggested settings above.
>> 2. pc256-bad.png is 34K and uses your settings above except changed to
>> IMAGEMODE PC256. You can see that the HATCH fill is completely
>> haywire.
>> In both cases the output PNG is 8 bit.

Hmmm, I did not see these two images posted. But regarding HATCH, I will 
defer to Thomas as I have not used HATCH before. I do remember various 
posts in the past, maybe yours, about hatching problems so you might try 
searching for them, also search the tickets for potential hatch bugs.

You might try creating a trivial mapfile that defines a polygon and 
applies a hatch to it. If that show a bug then submit a ticket for it. 
Basically the old GD code is deprecated and you have to use the AGG 
renderer. It antialiases everything so images do not compress as much as 
un-aliased images. If size is REALLY critical, then try JPEG output can 
compress to your hearts content. Its lossy but you can make them small 
and it does not support transparency if I remember correctly.

-Steve W

>> As always, I appreciate your insight.
>> Rich
>
>
> Attached is a GIF from MapServer 5.6. 39K and no HATCH issues. This is
> what I like to get from MapServer 6.0
>
>



More information about the mapserver-users mailing list