Color shifts using QUANTIZE_COLORS=256
Stephen Woodbridge
woodbri at SWOODBRIDGE.COM
Wed Aug 9 12:09:06 PDT 2006
Bart,
Thanks for the pointer to the bug. I will add some comments to it even
though it is closed.
-Steve
Bart van den Eijnden (OSGIS) wrote:
> Hi Steve,
>
> there is some info by Frank in the following bug report (assuming it is
> not outdated):
>
> http://mapserver.gis.umn.edu/bugs/show_bug.cgi?id=684
>
> Are you able to preprocess your tiles to 8-bit using a script that GDAL
> provides?
>
> My experience with PNG24 is that they become huge (aerial photos of
> about 500 by 500 pixels approach 1 Mb) and that ofcourse IE 6 (and
> lower) has problems with alpha transparency.
>
> Best regards,
> Bart
>
> Stephen Woodbridge wrote:
>
>> Hi all,
>>
>> Sorry for the cross-post, but this seems valid for both groups.
>>
>> I have mapserver configured to work with ka-map and things are working
>> fine except we have noticed color shifts in tiles. We are using:
>>
>> OUTPUTFORMAT
>> NAME PNG8
>> DRIVER "GD/PNG"
>> EXTENSION "png"
>> MIMETYPE "image/png"
>> IMAGEMODE RGBA
>> TRANSPARENT OFF
>> FORMATOPTION "QUANTIZE_FORCE=ON"
>> FORMATOPTION "QUANTIZE_DITHER=OFF"
>> FORMATOPTION "QUANTIZE_COLORS=256"
>> END
>>
>> in our mapfile and my hypotheses is that the GD QUANTIZE process is
>> selecting different colors based on the colors available in the various
>> meta-tiles. The mapserver source code calls the following function for
>> this process and from the GD manual:
>>
>>> void gdImageTrueColorToPalette(gdImagePtr im, int ditherFlag, int
>>> colorsWanted) gdImagePtr gdImageCreatePaletteFromTrueColor(gdImagePtr
>>> im, int ditherFlag, int colorsWanted) (FUNCTION)
>>>
>>> gdImageCreatePaletteFromTrueColor returns a new image.
>>> gdImageTrueColorToPalette permanently converts the existing image.
>>> The two functions are otherwise identical.
>>>
>>> The function converts a truecolor image to a palette-based image,
>>> using a high-quality two-pass quantization routine. If ditherFlag is
>>> set, the image will be dithered to approximate colors better, at the
>>> expense of some obvious "speckling." colorsWanted can be anything up
>>> to 256. If the original source image includes photographic
>>> information or anything that came out of a JPEG, 256 is strongly
>>> recommended. 100% transparency of a single transparent color in the
>>> original truecolor image will be preserved. There is no other support
>>> for preservation of alpha channel or transparency in the destination
>>> image.
>>>
>>> For best results, don't use this function -- write real truecolor
>>> PNGs and JPEGs. The disk space gain of conversion to palette is not
>>> great (for small images it can be negative) and the quality loss is
>>> ugly. However, the version of this function included in version
>>> 2.0.12 and later does do a better job than the version included prior
>>> to 2.0.12.
>>
>>
>> So, a few questions:
>>
>> 1) Has anyone looked into the impact of using PNG24 images on
>> a) image sizes
>> b) ka-map tile-cache sizing
>> c) compatibility with browsers
>> d) impact on browser memory usage or performance
>> 2) I thought Paul Spencer said to use DITHERED=OFF, is this correct
>> 3) Has anyone looked at the GD routine? Would it be possible to add a
>> palette of say 32 colors that would be "sticky" and priority over
>> other colors?
>>
>> -SteveW
>>
>>
>
>
More information about the MapServer-users
mailing list