Remove "colors" from image_info. Only use is in coder/jpeg.c.
Added artifact "jpeg:colors" to enable jpeg library quantization.
diff --git a/MagickCore/image.c b/MagickCore/image.c
index 8b559d7..79198c9 100644
--- a/MagickCore/image.c
+++ b/MagickCore/image.c
@@ -962,7 +962,6 @@
clone_info->transparent_color=image_info->transparent_color;
clone_info->dither=image_info->dither;
clone_info->monochrome=image_info->monochrome;
- clone_info->colors=image_info->colors;
clone_info->colorspace=image_info->colorspace;
clone_info->type=image_info->type;
clone_info->orientation=image_info->orientation;
@@ -4206,9 +4205,6 @@
if (option != (const char *) NULL)
(void) QueryColorCompliance(option,AllCompliance,&image->border_color,
&image->exception);
- option=GetImageOption(image_info,"colors");
- if (option != (const char *) NULL)
- image->colors=StringToUnsignedLong(option);
option=GetImageOption(image_info,"compose");
if (option != (const char *) NULL)
image->compose=(CompositeOperator) ParseCommandOption(MagickComposeOptions,
diff --git a/MagickCore/image.h b/MagickCore/image.h
index 23e1f89..01e5b70 100644
--- a/MagickCore/image.h
+++ b/MagickCore/image.h
@@ -169,7 +169,8 @@
columns, /* physical size of image */
rows,
depth, /* depth of image on read/write */
- colors; /* size of color table on read */
+ colors; /* Size of color table, or actual color count if known */
+ /* Only valid if image is not DirectClass */
PixelPacket
*colormap,
@@ -406,9 +407,6 @@
dither, /* dither enable-disable */
monochrome; /* read/write pcl,pdf,ps,xps as monocrome image */
- size_t
- colors; /* record the user requested color reduction! */
-
ColorspaceType
colorspace;
diff --git a/MagickWand/mogrify.c b/MagickWand/mogrify.c
index 2a13ce5..31503ef 100644
--- a/MagickWand/mogrify.c
+++ b/MagickWand/mogrify.c
@@ -6283,11 +6283,6 @@
image_info->channel=(ChannelType) ParseChannelOption(argv[i+1]);
break;
}
- if (LocaleCompare("colors",option+1) == 0)
- {
- image_info->colors=StringToUnsignedLong(argv[i+1]);
- break;
- }
if (LocaleCompare("colorspace",option+1) == 0)
{
if (*option == '+')
diff --git a/coders/jpeg.c b/coders/jpeg.c
index 060c8ba..64e9e59 100644
--- a/coders/jpeg.c
+++ b/coders/jpeg.c
@@ -1120,13 +1120,12 @@
image->compression=JPEGCompression;
image->interlace=JPEGInterlace;
#endif
- if ((image_info->colors > 8) && (image_info->colors <= 256))
+ option=GetImageOption(image_info,"jpeg:colors");
+ if (option != (const char *) NULL)
{
- /*
- Let the JPEG library quantize for us.
- */
+ /* Let the JPEG library quantize the image */
jpeg_info.quantize_colors=MagickTrue;
- jpeg_info.desired_number_of_colors=(int) image_info->colors;
+ jpeg_info.desired_number_of_colors=(int) StringToUnsignedLong(option);
}
option=GetImageOption(image_info,"jpeg:block-smoothing");
if (option != (const char *) NULL)
@@ -1180,8 +1179,10 @@
image->colorspace=YCbCrColorspace;
if (jpeg_info.out_color_space == JCS_CMYK)
image->colorspace=CMYKColorspace;
- if ((image_info->colors != 0) && (image_info->colors <= 256))
- if (AcquireImageColormap(image,image_info->colors,exception) == MagickFalse)
+ option=GetImageOption(image_info,"jpeg:colors");
+ if (option != (const char *) NULL)
+ if (AcquireImageColormap(image,StringToUnsignedLong(option),exception)
+ == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if ((jpeg_info.output_components == 1) &&
(jpeg_info.quantize_colors == MagickFalse))