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

Lime, Steve D (DNR) Steve.Lime at state.mn.us
Tue Oct 23 22:49:59 PDT 2012


Have you tried pre-computing image palettes? I've had some very good luck with rendering 24-bit PNGs and then running them through a pre-computed palette (there's an output format option for this). To do this I create a couple representative sample images using MapServer with 24-bit PNG output. I then use Photoshop to mosaic them into one image and then do a color reduction (usually to 128 colors). Then I use GDAL to extract the palette/color table. The advantages are colors that are very consistent between tiles and very small images. The rec. compass tiles (http://www.dnr.state.mn.us/maps/compass.html) use this approach (via MapServer/MapCache).

Steve

________________________________________
From: mapserver-users-bounces at lists.osgeo.org [mapserver-users-bounces at lists.osgeo.org] on behalf of Stephen Woodbridge [woodbri at swoodbridge.com]
Sent: Tuesday, October 23, 2012 11:29 PM
To: Richard Greenwood
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] 8 bit versus 24 bit output in MapServer 6.x

On 10/23/2012 11:24 PM, Richard Greenwood 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.
>
> As always, I appreciate your insight.
> Rich
>

Ahh, just got this. I'm not sure I have anything useful to say other
than: If it hurts, don't do that! :) Seriously, if you can live with a
jpeg, you might get the results you want in a smaller size, but I have
not tried it. That said, this does look like a bug, so maybe Thomas has
something to add.

-Steve W

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users




More information about the mapserver-users mailing list