[mapserver-dev] Paletted PNG and Quantization
thomas bonfort
thomas.bonfort at gmail.com
Fri Apr 13 14:21:57 EDT 2012
If you don't add QUANTIZE_COLORS, only the colors given in the palette
will be used. If you add it, then a png file with that number of
colors will be created, and QUANTIZE_COLOR-num_palette_entries will be
added to the final palette, computed from the image data.
If the docs need updating to reflect this, please submit a doc ticket
or even better a pull request with the updated explanations.
cheers,
thomas
On Fri, Apr 13, 2012 at 20:09, Christy Nieman <cnieman at dmsolutions.ca> wrote:
> 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
>
> _______________________________________________
> 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