[mapserver-dev] Paletted PNG and Quantization

Christy Nieman cnieman at dmsolutions.ca
Fri Apr 13 14:09:00 EDT 2012


Steve W,

I'm using AGG/PNG, but, I also tried with CAIRO/PNG and got the same 
results.

I used to just have to specify a palette file and PALETTE_FORCE=TRUE, 
but now to get the same functionality, I need to also have 
QUANTIZE_COLORS=<a value>.

I think this changed with MS 6.0, and I was wondering if this is a bug 
in the code (i.e. I shouldn't have to have QUANTIZE_COLORS specified), 
or if it is an error in the documentation (i.e. the docs should say that 
along with PALETTE and PALETTE_FORCE you need QUANTIZE_COLORS).

Christy

On 04/13/2012 01:25 PM, Stephen Woodbridge wrote:
> I have used it with tile generation and it performs quite well at 
> avoiding the color shifts between tiles, but setting a palette does a 
> better job. I have not tried an explicit palette in a while but I do 
> not maintain a tile cache here.
>
> Given it a try. Also try my output block and swap you explicit palette 
> and see if the quality issues are resovled. You did post your whole 
> output block so I'm not sure if there were other thing affecting the 
> quality, like using driver GD/PNG vs AGG/PNG.
>
> -Steve W
>
> On 4/13/2012 1:06 PM, Christy Nieman wrote:
>> Thanks for the reply, SteveW.
>>
>> How does this perform with for creating tiled maps? The reason I use a
>> palette is to make sure colours of features are the same between tiles.
>>
>> Christy
>>
>> On 04/13/2012 12:45 PM, Stephen Woodbridge wrote:
>>> Christy,
>>>
>>> You might try 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
>>>
>>> You can replace FORMATOPTION "QUANTIZE_NEW=ON" with your two lines
>>> below I think.
>>>
>>> -Steve W
>>>
>>> On 4/13/2012 11:22 AM, Christy Nieman wrote:
>>>> Hi all,
>>>>
>>>> Just wanted to make sure that I'm doing this right before filing a 
>>>> bug:
>>>>
>>>> With MapServer 6.0.2 and master, I wanted to have an 8-bit PNG with 
>>>> the
>>>> colours defined by a palette. In previous versions of MapServer, all I
>>>> had to do was put
>>>>
>>>> FORMATOPTION "PALETTE_FORCE=TRUE"
>>>> FORMATOPTION
>>>> "PALETTE=/mnt/data1/mapsherpa_v3_demo_data/map/map_overlay/templates/palette_rgba.txt" 
>>>>
>>>>
>>>>
>>>> in the OUTPUTFORMAT. When I did this in MapServer >= 6, I got a very
>>>> ugly output (looked like there was hardly any anti-aliasing 
>>>> happening).
>>>> Looking in mapimageio.c around line 422, I discovered that I needed to
>>>> also have FORMATOPTION "QUANTIZE_COLORS=<a number greater than 0>" in
>>>> the OUTPUTFORMAT or no quantization would happen to add the required
>>>> colours for anti-aliasing.
>>>>
>>>> The documentation for the AGG/PNG driver explicitely says that
>>>> “PALETTE_FORCE=on” is used to reduce image depth with a predefined
>>>> palette. This option is incompatible with the previous quantization
>>>> options. But this would seem to no longer be true.
>>>>
>>>> Is this a documentation error, or a problem in the mapimageio.c code?
>>>>
>>>> Thanks,
>>>> Christy
>>>> -- 
>>>> Christy Nieman
>>>> GIS Technician
>>>> DM Solutions Group, Inc.
>>>> Email: cnieman at dmsolutions.ca <mailto:cnieman at dmsolutions.ca>
>>>> Web: http://dmsolutions.ca
>>>>
>>>>
>>>> _______________________________________________
>>>> mapserver-dev mailing list
>>>> mapserver-dev at lists.osgeo.org
>>>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>>>
>>> _______________________________________________
>>> mapserver-dev mailing list
>>> mapserver-dev at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>> _______________________________________________
>> mapserver-dev mailing list
>> mapserver-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev


More information about the mapserver-dev mailing list