Hi! This is really god news, unfortunately there is still an issue regarding this functionality in conjunction with the WMS transparent parameter. When set to true, the resulting 8bit image has a black background, not transparent as it should be.
Regards, Pål Kristensen tbonfort wrote: > > hi all, > > I committed the implementation to enable forced palette and color > reduction via quantization for RGBA images. These options greatly > reduce image size for png output when using IMAGEMODE RGBA. > > the tracking ticket is http://trac.osgeo.org/mapserver/ticket/2436 , > which contains examples of image size reduction you can hope to obtain > when using the option > > you'll need a recent version of the mapserver source tree from SVN ( > instructions to obtain it: > http://mapserver.gis.umn.edu/development/cvs/ ) > > it is activated when the ./configure script is run with the > --with-experimental-png switch, which checks for the libpng headers. > this means that the libpng headers have to be installed and accessible > on your system (apt-get install libpng-dev or the equivalent with > yum/yast/etc...) > > to activate these outputs in your mapfiles you'll need to set some > FORMATOPTION entries to the wanted OUTPUTFORMATs, eg > > ************************ > to force quantization > ************************ > (creates a paletted png, with the palette automatically > created/selected for each rendered image) > > OUTPUTFORMAT > NAME 'AGGAQ' > DRIVER AGG/PNG # not AGG specific, also works with GD. PNG is > mandatory though > IMAGEMODE RGBA # only for rgba imagemodes > MIMETYPE "image/png" > > # this is the important part > FORMATOPTION "QUANTIZE_FORCE=ON" > > # this specifies the number of colors wanted in the final image > # 256 is the typically wanted value > # values 17 to 255 are possible but don't really make sense as there's > little reduction in file size compared to 256 (each pixel is still > stored with 8 bits, only the palette is smaller) > # 16 greatly reduces image size (and quality, no magic) > FORMATOPTION "QUANTIZE_COLORS=256" > END > > > ********************************************** > to use a specified precomputed palette > ********************************************** > (faster than quantization, and guarantees colors are consistent > whatever the image created, but less flexible as the palette has to be > precomputed and is fixed whatever is in the image) > > OUTPUTFORMAT > NAME 'AGGAP' > DRIVER AGG/PNG > IMAGEMODE RGBA > MIMETYPE "image/png" > > # the important part > FORMATOPTION "PALETTE_FORCE=TRUE" > FORMATOPTION "PALETTE=/gro/jsigmaps/palette.txt" > END > > here the palette file must be specified with an absolute path, and > contains at most 256 lines, each consisting of an r,g,b,a quadruplet, > eg: > > 0,0,0,0 > 127,127,127,2 > 196,226,251,237 > 170,170,170,2 > 191,191,191,4 > 196,225,251,233 > ... > snip > ... > 163,189,242,57 > 137,158,242,56 > 118,137,241,48 > 184,213,245,75 > > to obtain this palette, take a typical (32bit rgba png) image you will > want to display, use your favorite image editor to reduce the number > of colors (photoshop using "save web image" and selecting png, or the > commandline utilities pngquant > [http://libpng.org/pub/png/apps/pngquant.html] or neuquant > [http://members.ozemail.com.au/~dekker/NEUQUANT.HTML], etc ) and then > extract (and transform to the required r,g,b,a format) the computed > palette to the palette file. ( pngcheck > [http://www.libpng.org/pub/png/apps/pngcheck.html] with its -p option > and some scripting can be used for this ) > > > > these two options are still considered experimental, and any feedback > you might give is welcome ( be it in the ./configure script, > compiling, or image results ) > > cheers, > thomas > > ps: email sent for documentation purposes until the official > documentation is created/released on the main documentation site > > -- View this message in context: http://www.nabble.com/forced-palette-and-quantization-for-RGBA-images-tp14645870p14712888.html Sent from the Mapserver - User mailing list archive at Nabble.com.
