]> granicus.if.org Git - imagemagick/commitdiff
Properly set image->colorspace in the PNG decoder
authorGlenn Randers-Pehrson <glennrp@gmail.com>
Sun, 30 Jul 2017 01:06:12 +0000 (21:06 -0400)
committerGlenn Randers-Pehrson <glennrp@gmail.com>
Sun, 30 Jul 2017 01:06:12 +0000 (21:06 -0400)
ChangeLog
coders/png.c

index 45ce2f6fc9307f0a9b6d88465f9d3c45fa973079..b4d1adcb78cbb0df1393199eaa9dc21b925215a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-07-29  7.0.6-5 Glenn Randers-Pehrson <glennrp@image...>
+  * Properly set image->colorspace in the PNG decoder (previously
+    it was setting image->gamma, but only setting image->colorspace
+    for grayscale and gray-alpha images.  Reference
+    https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=32418).
+
 2017-07-29  7.0.6-5 Cristy  <quetzlzacatenango@image...>
   * Off by one error for gradient coder (reference
     https://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=32416).
index e3b8f705268d0ad35701a49288932376418b084d..595c4c3ddde06cb5f859147b9d8119354a2b8af3 100644 (file)
@@ -3154,6 +3154,36 @@ static Image *ReadOnePNGImage(MngInfo *mng_info,
 
       image->gamma = image_gamma;
     }
+  else
+    {
+      double
+        image_gamma = image->gamma;
+
+      (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+         "    image->gamma=%f",(float) image_gamma);
+
+      if (image_gamma > 0.75)
+        {
+          /* Set image->rendering_intent to Undefined,
+           * image->colorspace to GRAY, and reset image->chromaticity.
+           */
+          image->intensity = Rec709LuminancePixelIntensityMethod;
+          SetImageColorspace(image,RGBColorspace,exception);
+        }
+      else
+        {
+          RenderingIntent
+            save_rendering_intent = image->rendering_intent;
+          ChromaticityInfo
+            save_chromaticity = image->chromaticity;
+
+          SetImageColorspace(image,sRGBColorspace,exception);
+          image->rendering_intent = save_rendering_intent;
+          image->chromaticity = save_chromaticity;
+        }
+
+      image->gamma = image_gamma;
+    }
 
   (void)LogMagickEvent(CoderEvent,GetMagickModule(),
       "    image->colorspace=%d",(int) image->colorspace);
@@ -4250,8 +4280,16 @@ static Image *ReadPNGImage(const ImageInfo *image_info,
            image->chromaticity.white_point.y>0.3289f &&
            image->chromaticity.white_point.y<0.3291f))
     {
+       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+          "SetImageColorspace to RGBColorspace");
        SetImageColorspace(image,RGBColorspace,exception);
     }
+    else
+    {
+       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+          "NOT SetImageColorspace to RGBColorspace, image->gamma=%g",
+        image->gamma);
+    }
 
   if (logging != MagickFalse)
     {