From 83c306dd3a2ed767effb16e725f4a0e338d978a6 Mon Sep 17 00:00:00 2001 From: Cristy Date: Tue, 26 Dec 2017 19:11:41 -0500 Subject: [PATCH] https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=33274 --- MagickCore/attribute.c | 52 +++++++++++++----------------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/MagickCore/attribute.c b/MagickCore/attribute.c index edf451dfc..59a143e07 100644 --- a/MagickCore/attribute.c +++ b/MagickCore/attribute.c @@ -1256,38 +1256,32 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type, { case BilevelType: { - if (SetImageMonochrome(image,exception) == MagickFalse) - { - status=TransformImageColorspace(image,sGRAYColorspace,exception); - (void) NormalizeImage(image,exception); - quantize_info=AcquireQuantizeInfo(image_info); - quantize_info->number_colors=2; - quantize_info->colorspace=sGRAYColorspace; - status=QuantizeImage(quantize_info,image,exception); - quantize_info=DestroyQuantizeInfo(quantize_info); - } + status=TransformImageColorspace(image,sGRAYColorspace,exception); + (void) NormalizeImage(image,exception); + quantize_info=AcquireQuantizeInfo(image_info); + quantize_info->number_colors=2; + quantize_info->colorspace=sGRAYColorspace; + status=QuantizeImage(quantize_info,image,exception); + quantize_info=DestroyQuantizeInfo(quantize_info); image->alpha_trait=UndefinedPixelTrait; break; } case GrayscaleType: { - if (SetImageGray(image,exception) == MagickFalse) - status=TransformImageColorspace(image,sGRAYColorspace,exception); + status=TransformImageColorspace(image,sGRAYColorspace,exception); image->alpha_trait=UndefinedPixelTrait; break; } case GrayscaleAlphaType: { - if (SetImageGray(image,exception) == MagickFalse) - status=TransformImageColorspace(image,sGRAYColorspace,exception); + status=TransformImageColorspace(image,sGRAYColorspace,exception); if (image->alpha_trait == UndefinedPixelTrait) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); break; } case PaletteType: { - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - status=TransformImageColorspace(image,sRGBColorspace,exception); + status=TransformImageColorspace(image,sRGBColorspace,exception); if ((image->storage_class == DirectClass) || (image->colors > 256)) { quantize_info=AcquireQuantizeInfo(image_info); @@ -1303,8 +1297,7 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type, ChannelType channel_mask; - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - status=TransformImageColorspace(image,sRGBColorspace,exception); + status=TransformImageColorspace(image,sRGBColorspace,exception); if (image->alpha_trait == UndefinedPixelTrait) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); channel_mask=SetImageChannelMask(image,AlphaChannel); @@ -1317,8 +1310,7 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type, } case PaletteAlphaType: { - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - status=TransformImageColorspace(image,sRGBColorspace,exception); + status=TransformImageColorspace(image,sRGBColorspace,exception); if (image->alpha_trait == UndefinedPixelTrait) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception); quantize_info=AcquireQuantizeInfo(image_info); @@ -1329,8 +1321,7 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type, } case TrueColorType: { - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - status=TransformImageColorspace(image,sRGBColorspace,exception); + status=TransformImageColorspace(image,sRGBColorspace,exception); if (image->storage_class != DirectClass) status=SetImageStorageClass(image,DirectClass,exception); image->alpha_trait=UndefinedPixelTrait; @@ -1338,8 +1329,7 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type, } case TrueColorAlphaType: { - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - status=TransformImageColorspace(image,sRGBColorspace,exception); + status=TransformImageColorspace(image,sRGBColorspace,exception); if (image->storage_class != DirectClass) status=SetImageStorageClass(image,DirectClass,exception); if (image->alpha_trait == UndefinedPixelTrait) @@ -1348,12 +1338,7 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type, } case ColorSeparationType: { - if (image->colorspace != CMYKColorspace) - { - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - status=TransformImageColorspace(image,sRGBColorspace,exception); - status=TransformImageColorspace(image,CMYKColorspace,exception); - } + status=TransformImageColorspace(image,CMYKColorspace,exception); if (image->storage_class != DirectClass) status=SetImageStorageClass(image,DirectClass,exception); image->alpha_trait=UndefinedPixelTrait; @@ -1361,12 +1346,7 @@ MagickExport MagickBooleanType SetImageType(Image *image,const ImageType type, } case ColorSeparationAlphaType: { - if (image->colorspace != CMYKColorspace) - { - if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse) - status=TransformImageColorspace(image,sRGBColorspace,exception); - status=TransformImageColorspace(image,CMYKColorspace,exception); - } + status=TransformImageColorspace(image,CMYKColorspace,exception); if (image->storage_class != DirectClass) status=SetImageStorageClass(image,DirectClass,exception); if (image->alpha_trait == UndefinedPixelTrait) -- 2.40.0