Important notice: the development of WideImage 1.0 branch is discontinued.
Please visit
http://wideimage.sourceforge.net for the new version of library and documentation.
This web site will remain accessible to serve as documentation for the old versions of the library.
For help on migration, please refer
to the
migration
guide.
wiImage::asPalette()
See:
List of operations
Signature
wiImage::asPalette($nColors = 255, $dither = null, $matchPalette = true)
Parameters
- result (wiPaletteImage): a palette image
Description
Returns a copy of itself, converted to wiPaletteImage. $nColors specifies the number of colors (max 255), $dither enables/disables mixdown dithering, $matchPalette specifies whether the palette should be corrected with
imagecolormatch()∞ after converting to a palette image.
Notes
- For wiPaletteImage objects, this returns an ordinary copy.
As for $dither and $matchPalette, I've played with these two a lot and I'm not sure what are the best settings. This is what I found out (your experience may differ):
- If you want to retain a single-color transparency information (not alpha channel), use $dither = true.
- $matchPalette can improve the image quality, bun can affect transparency.
Examples
// load a truecolor png and save it as an 8-bit gif with dithering and no palette matching
$img = wiImage::load('/path/to/an/image.png');
$img->asPalette(255, true, false)->saveToFile('palette-image.png');
CategoryDocApi
There are no comments on this page. [Add comment]