MagickQuantizeImage behaviour, feature or bug?
Posted: 2015-01-03T17:06:25-07:00
When you call MagickQuantizeImage with the maximum number of colors equal to or larger than the number of pixels in the image, and using the gray color-space, the image remains unchanged as a color image.
This seems to only happen when calling ImageMagick through C code - I was unable to replicate the problem with the same image through the command line convert utility.
A user of PHP Imagick reported this issue. They expected the image to be changed to gray colorspace, but it's not entirely obvious what the correct behaviour should be to me.
This seems to only happen when calling ImageMagick through C code - I was unable to replicate the problem with the same image through the command line convert utility.
A user of PHP Imagick reported this issue. They expected the image to be changed to gray colorspace, but it's not entirely obvious what the correct behaviour should be to me.
Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <wand/MagickWand.h>
int main(int argc,char **argv) {
MagickWand *magick_wand;
MagickBooleanType status;
MagickWandGenesis();
magick_wand = NewMagickWand();
//This is a color image
status = MagickReadImage(magick_wand, "./Biter_500.jpg");
MagickScaleImage(magick_wand, 16, 16);
MagickQuantizeImage(
magick_wand,
//Changing to 255 makes the image change to grayscale
256,
GRAYColorspace,
0,
0,
0
);
status = MagickWriteImages(magick_wand, "./67258.jpg", MagickTrue);
MagickWandTerminus();
return(0);
}