From: glennrp Date: Wed, 22 Aug 2012 13:59:50 +0000 (+0000) Subject: Set image->colorspace to GRAY when input is a grayscale image with gamma=1.0 X-Git-Tag: 7.0.1-0~5086 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e88af7706d1540872ed85dd059a8faf3339d3f5b;p=imagemagick Set image->colorspace to GRAY when input is a grayscale image with gamma=1.0 --- diff --git a/coders/png.c b/coders/png.c index f0872f4a7..c561e59f2 100644 --- a/coders/png.c +++ b/coders/png.c @@ -2147,6 +2147,9 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, (void)LogMagickEvent(CoderEvent,GetMagickModule(), " image->rendering_intent=%d",(int) image->rendering_intent); + + (void)LogMagickEvent(CoderEvent,GetMagickModule(), + " image->colorspace=%d",(int) image->colorspace); } intent=Magick_RenderingIntent_to_PNG_RenderingIntent(image->rendering_intent); @@ -2791,16 +2794,20 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, if (((int) ping_color_type == PNG_COLOR_TYPE_GRAY) || ((int) ping_color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) { - if (!png_get_valid(ping,ping_info,PNG_INFO_gAMA) && + if ((!png_get_valid(ping,ping_info,PNG_INFO_gAMA) || + image->gamma == 1.0) && !png_get_valid(ping,ping_info,PNG_INFO_cHRM) && !png_get_valid(ping,ping_info,PNG_INFO_sRGB)) { /* Set image->gamma to 1.0, image->rendering_intent to Undefined, - * and reset image->chromaticity. + * image->colorspace to GRAY, and reset image->chromaticity. */ SetImageColorspace(image,GRAYColorspace,exception); } } + + (void)LogMagickEvent(CoderEvent,GetMagickModule(), + " image->colorspace=%d",(int) image->colorspace); if (((int) ping_color_type == PNG_COLOR_TYPE_PALETTE) || ((int) ping_color_type == PNG_COLOR_TYPE_GRAY))