[MAPSERVER-USERS] help! agg palette quantize algorithm imperfection

Stephen Woodbridge woodbri at swoodbridge.com
Fri Jun 6 11:00:24 EDT 2008


Hey, that's what they pay you the BIG BUCKS for! :)

Write a perl/bash/{your favorite} script to grab all the COLOR lines 
from you mapfile and reformat the r g b to r,g,b in you palette file.

I have a few hundred symbols in my symbol library, but I only use about 
10 of them regularly so I made sure the primary colors were also in the 
palette file. I make the script add them so I don't have to think about it.

It sounds like a big deal, but it not that bad.

YMMV,
   -Steve W

BrainDrain wrote:
> Thanks, i already read about preparing palette index file & I see 2
> obstacles:
> 1) I need to monitor my map file (big size) to keep relevant my palette
> file. It is inflexible to extract rgb colors used in pixmap symbols
> (hundreds, updatable). Can I use html palette for ex. (or any other
> 'universal' palette) - to make this process not so time-consuming?
> 2) If I have strict palette, can I be sure that agg renderer will always use
> the nearest(?) color from my palette?
> 
> pagameba wrote:
>> Use:
>>
>> OUTPUTFORMAT
>>    OUTPUTFORMAT
>>    NAME "AGG_Q"
>>    DRIVER "AGG/PNG"
>>    MIMETYPE "image/png; mode=8bit"
>>    IMAGEMODE RGB
>>    EXTENSION "png"
>>    FORMATOPTION "PALETTE_FORCE=TRUE"
>>    FORMATOPTION "PALETTE=/path/to/palette.txt"
>> END
>>
>> where palette.txt is a text file with RGB tuples in the form:
>>
>> RRR,GGG,BBB
>>
>> For example:
>>
>> 0,0,0
>> 255,255,255
>> 127,127,127
>>
>> MapServer will use AGG 24 bit rendering but reduce the output file to  
>> 8 bit and reserve the colours in your palette.txt file.  This will  
>> give you consistent colours for the ones you care about.   
>> Specifically, you should reserve all the colours that you actually  
>> reference in your map file plus any colours of pixmap symbols.  Don't  
>> put in more colours than you actually need to because MapServer needs  
>> to use whatever space is left (255 less your colours) for antialiasing.
>>
>> Cheers
>>
>> Paul
>>
>> On 6-Jun-08, at 7:53 AM, BrainDrain wrote:
>>
>>> I use this output format in my map file:
>>> OUTPUTFORMAT
>>> NAME "AGG_Q"
>>> DRIVER "AGG/PNG"
>>> MIMETYPE "image/png; mode=8bit"
>>> IMAGEMODE RGB
>>> EXTENSION "png"
>>> FORMATOPTION "QUANTIZE_FORCE=ON"
>>> FORMATOPTION "QUANTIZE_DITHER=OFF"
>>> FORMATOPTION "QUANTIZE_COLORS=256"
>>> END
>>> but every time map draw called (or map image requested fom cgi  
>>> mapserv.exe)
>>> polygons has a little difference in fill color (I think this is  
>>> because
>>> color palette recalculated slightly different each time). This is
>>> unacceptable for me. How can i correct this? (maybe some  
>>> FORMATOPTION?)
>>> -- 
>>> View this message in context:
>>> http://www.nabble.com/help%21-agg-palette-quantize-algorithm-imperfection-tp17667733p17667733.html
>>> Sent from the Mapserver - User mailing list archive at Nabble.com.
>>>
>>> _______________________________________________
>>> mapserver-users mailing list
>>> mapserver-users at lists.osgeo.org
>>> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>>
>> __________________________________________
>>
>>     Paul Spencer
>>     Chief Technology Officer
>>     DM Solutions Group Inc
>>     http://www.dmsolutions.ca/
>> _______________________________________________
>> 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