I have several images that I process with ImageMagick. In this case, I convert RGBA PNG to indexed PNG. If I use the convert tool, I have reasonable control over the number of colors in the indexed PNG:
$ convert infile.png -colors 128 outfile.png $ identify outfile.png outfile.png PNG 77x77 77x77+0+0 8-bit PseudoClass 91c 3.03KiB 0.000u 0:00.000
It seems that reducing the number of colors is significant (91 <128) I am trying to do the same conversion using MagickWand MagickQuantizeImage(wand, 128, RGBColorspace, tree_depth=1, 0, 0) . Function Signature
MagickBooleanType MagickQuantizeImage( MagickWand *wand, const size_t number_colors, ColorspaceType colorspace, const size_t treedepth, const MagickBooleanType dither, const MagickBooleanType measure_error)
The end result is an image with too few colors (11 in total!):
$ identify wandoutfile.png wandoutfile.png PNG 77x77 77x77+0+0 8-bit PseudoClass 11c 1.31KiB 0.000u 0:00.000
Does anyone know how to achieve color reduction with MagickWand (without destroying the image in the process?)
Thanks!
Troy J. Farrell
source share