]> granicus.if.org Git - imagemagick/commitdiff
Don't write a text:density chunk in a PNG output file.
authorglennrp <glennrp@git.imagemagick.org>
Mon, 7 Mar 2011 00:08:23 +0000 (00:08 +0000)
committerglennrp <glennrp@git.imagemagick.org>
Mon, 7 Mar 2011 00:08:23 +0000 (00:08 +0000)
ChangeLog
coders/png.c

index bb7f971b33c49a8817a2e2db5281530be5ffcd0b..39fd32fb2302a261ed429cbb84e22243e56ebd0f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,10 @@
   * Throw error message when the requested color-type or bit-depth
     cannot be written by the PNG encoder (error was being thrown
     into the wrong image structure).  (Reference
-http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18162).
+    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18162).
+  * Don't write a PNG text chunk with "density" keyword that overrides the
+    PNG pHYs chunk (reference
+    http://www.imagemagick.org/discourse-server/viewtopic.php?f=3&t=18225).
 
 2011-03-06  6.6.8-2 Cristy  <quetzlzacatenango@image...>
   * Support the Radiance HDR image format.
index 45427d742debabd1925b6730e938d789e728cb4d..f67e199cf4417a379b985f1af2934adb844b7f0d 100644 (file)
@@ -7776,9 +7776,6 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
           (void) CloseBlob(image);
       image_info=DestroyImageInfo(image_info);
       image=DestroyImage(image);
-      (void) ThrowMagickException(&IMimage->exception,
-          GetMagickModule(),CoderError,
-          "PNG write has failed","`%s'",IMimage->filename);
       return(MagickFalse);
     }
   /*
@@ -8111,9 +8108,9 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
            if (image->colors == 0)
            {
               /* DO SOMETHING */
-              (void) ThrowMagickException(&IMimage->exception,
+              (void) ThrowMagickException(&image->exception,
                  GetMagickModule(),CoderError,
-                "image has 0 colors", "`%s'",IMimage->filename);
+                "image has 0 colors", "`%s'","");
            }
 
            while ((int) (one << ping_bit_depth) < (ssize_t) image_colors)
@@ -9386,38 +9383,41 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
         text;
 
       value=GetImageProperty(image,property);
-      if (value != (const char *) NULL)
+      if (LocaleCompare(property,"density") != 0)
         {
-          text=(png_textp) png_malloc(ping,(png_uint_32) sizeof(png_text));
-          text[0].key=(char *) property;
-          text[0].text=(char *) value;
-          text[0].text_length=strlen(value);
-
-          if (ping_exclude_tEXt != MagickFalse)
-             text[0].compression=PNG_TEXT_COMPRESSION_zTXt;
+        if (value != (const char *) NULL)
+          {
+            text=(png_textp) png_malloc(ping,(png_uint_32) sizeof(png_text));
+            text[0].key=(char *) property;
+            text[0].text=(char *) value;
+            text[0].text_length=strlen(value);
 
-          else if (ping_exclude_zTXt != MagickFalse)
-             text[0].compression=PNG_TEXT_COMPRESSION_NONE;
+            if (ping_exclude_tEXt != MagickFalse)
+               text[0].compression=PNG_TEXT_COMPRESSION_zTXt;
 
-          else
-          {
-             text[0].compression=image_info->compression == NoCompression ||
-               (image_info->compression == UndefinedCompression &&
-               text[0].text_length < 128) ? PNG_TEXT_COMPRESSION_NONE :
-               PNG_TEXT_COMPRESSION_zTXt ;
-          }
+            else if (ping_exclude_zTXt != MagickFalse)
+               text[0].compression=PNG_TEXT_COMPRESSION_NONE;
 
-          if (logging != MagickFalse)
+            else
             {
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                "  Setting up text chunk");
-
-              (void) LogMagickEvent(CoderEvent,GetMagickModule(),
-                "    keyword: %s",text[0].key);
+               text[0].compression=image_info->compression == NoCompression ||
+                 (image_info->compression == UndefinedCompression &&
+                 text[0].text_length < 128) ? PNG_TEXT_COMPRESSION_NONE :
+                 PNG_TEXT_COMPRESSION_zTXt ;
             }
 
-          png_set_text(ping,ping_info,text,1);
-          png_free(ping,text);
+            if (logging != MagickFalse)
+              {
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "  Setting up text chunk");
+
+                (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                  "    keyword: %s",text[0].key);
+              }
+
+            png_set_text(ping,ping_info,text,1);
+            png_free(ping,text);
+          }
         }
       property=GetNextImageProperty(image);
     }
@@ -9472,9 +9472,9 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info,
     }
   if (mng_info->write_mng && !mng_info->need_fram &&
       ((int) image->dispose == 3))
-     (void) ThrowMagickException(&IMimage->exception,GetMagickModule(),
+     (void) ThrowMagickException(&image->exception,GetMagickModule(),
        CoderError,"Cannot convert GIF with disposal method 3 to MNG-LC",
-       "`%s'",IMimage->filename);
+       "`%s'",image->filename);
 
   /*
     Free PNG resources.