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 f0872f4..c561e59 100644
--- a/coders/png.c
+++ b/coders/png.c
@@ -2147,6 +2147,9 @@
 
     (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 @@
   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))