From: Cristy Date: Sun, 10 Dec 2017 01:17:08 +0000 (-0500) Subject: Return linear grayscale for -colorspace RGB -colorspace gray X-Git-Tag: 7.0.7-15~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4a8bd31da0878d12247b01be9b3d31bf5ede46e3;p=imagemagick Return linear grayscale for -colorspace RGB -colorspace gray --- diff --git a/MagickCore/colorspace.c b/MagickCore/colorspace.c index e2f1bdf2e..c281918a2 100644 --- a/MagickCore/colorspace.c +++ b/MagickCore/colorspace.c @@ -320,8 +320,8 @@ static MagickBooleanType sRGBTransformImage(Image *image, status=MagickFalse; } image_view=DestroyCacheView(image_view); - image->type=image->alpha_trait == UndefinedPixelTrait ? ColorSeparationType : - ColorSeparationAlphaType; + image->type=image->alpha_trait == UndefinedPixelTrait ? + ColorSeparationType : ColorSeparationAlphaType; if (SetImageColorspace(image,colorspace,exception) == MagickFalse) return(MagickFalse); return(status); @@ -1094,14 +1094,14 @@ MagickExport MagickBooleanType SetImageColorspace(Image *image, assert(exception->signature == MagickCoreSignature); if (image->colorspace == colorspace) return(MagickTrue); - image->colorspace=colorspace; image->rendering_intent=UndefinedIntent; image->gamma=1.000/2.200; (void) ResetMagickMemory(&image->chromaticity,0,sizeof(image->chromaticity)); type=image->type; if (IsGrayColorspace(colorspace) != MagickFalse) { - if ((image->intensity == Rec601LuminancePixelIntensityMethod) || + if ((IsRGBColorspace(image->colorspace) != MagickFalse) || + (image->intensity == Rec601LuminancePixelIntensityMethod) || (image->intensity == Rec709LuminancePixelIntensityMethod)) image->gamma=1.000; type=GrayscaleType; @@ -1126,6 +1126,7 @@ MagickExport MagickBooleanType SetImageColorspace(Image *image, image->chromaticity.white_point.y=0.3290; image->chromaticity.white_point.z=0.3583; } + image->colorspace=colorspace; status=SyncImagePixelCache(image,exception); image->type=type; return(status); @@ -1284,6 +1285,12 @@ MagickExport MagickBooleanType TransformImageColorspace(Image *image, if ((image->colorspace == GRAYColorspace) && (image->gamma != 1.0) && (colorspace == sRGBColorspace)) return(SetImageColorspace(image,colorspace,exception)); + if ((image->colorspace == RGBColorspace) && (image->gamma != 1.0) && + (colorspace == RGBColorspace)) + return(SetImageColorspace(image,colorspace,exception)); + if ((image->colorspace == RGBColorspace) && (image->gamma == 1.0) && + (colorspace == GRAYColorspace)) + return(SetImageColorspace(image,colorspace,exception)); if (colorspace == UndefinedColorspace) return(SetImageColorspace(image,colorspace,exception)); /*