From: glennrp Date: Wed, 30 Mar 2011 18:47:21 +0000 (+0000) Subject: Store PNG IHDR data as properties X-Git-Tag: 7.0.1-0~7813 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=147bc91f6859c598c4f57b6a162111b2f63614d9;p=imagemagick Store PNG IHDR data as properties --- diff --git a/ChangeLog b/ChangeLog index f2de5b116..c8342647f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2011-03-30 6.6.9-2 Anthony Thyssen +2011-03-30 6.6.9-2 Glenn Randers-Pehrson + * Revised the png decoder to store the PNG IHDR data as properties, for + later retrieval and reporting by "identify", so users can easily and + reliably discover the color-type, bit-depth, etc that were in the input + PNG datastream. + +2011-03-30 6.6.9-2 Anthony Thyssen * Add a "Resize" distortion method (distort equivalent of -resize). * Special CLI handling so -distort Resize takes a "geometry" argument. @@ -8,7 +14,7 @@ 2011-03-29 6.6.9-1 Cristy * New version 6.6.9-1. -2011-03-29 6.6.9-1 Anthony Thyssen +2011-03-29 6.6.9-1 Anthony Thyssen * Fix AdaptiveResizeImage() to use 'Mesh' Interpolation, and fix its coordinate handling, as originally defined. @@ -23,7 +29,7 @@ * Optimize bilinear interpolation. * Remove version from etc folder and instead use /etc/ImageMagick. -2011-03-28 6.6.9-0 Anthony Thyssen +2011-03-28 6.6.9-0 Anthony Thyssen * Separated complex cropping function from TransformImage() as a new function CropImageToTiles(). This new function returns either the new cropped image, or a list of tiles, according to geometry, without @@ -33,7 +39,7 @@ 2011-03-27 6.6.8-10 Cristy * New version 6.6.8-10. -2011-03-27 6.6.8-10 Anthony Thyssen +2011-03-27 6.6.8-10 Anthony Thyssen * Modified image handling in MogrifyImages() and MogrifyImage() which improves overall handling, and allows correct %p, %n and the %[fx:..] 't' and 'n' escape usage to work correctly. @@ -42,19 +48,19 @@ 2011-03-26 6.6.8-9 Cristy * New version 6.6.8-9. -2011-03-25 6.6.8-9 Cristy +2011-03-25 6.6.8-9 Cristy * Add InterpolateMagickPixelPacket() method. * Add support for the %[opaque] property. 2011-03-25 6.6.8-8 Cristy * New version 6.6.8-8. -2011-03-25 6.6.8-8 Cristy +2011-03-25 6.6.8-8 Cristy * Fix memory access bug in CloneString() (reference http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=18382). * Avoid infinite loop when no space is available in MagickFormatCaption(). -2011-03-25 6.6.8-8 Anthony Thyssen +2011-03-25 6.6.8-8 Anthony Thyssen * Removed the fix for %p and %n escapes, as it was not working right 2011-03-24 6.6.8-7 Cristy diff --git a/coders/png.c b/coders/png.c index 6b675aff6..bed1e05b4 100644 --- a/coders/png.c +++ b/coders/png.c @@ -2289,6 +2289,34 @@ static Image *ReadOnePNGImage(MngInfo *mng_info, } } } + +#if 1 + + /* Set some properties for reporting by "identify" */ + char + msg[MaxTextExtent]; + + /* encode ping_width, ping_height, ping_bit_depth, ping_color_type, + ping_interlace_method in value */ + + (void) FormatMagickString(msg,MaxTextExtent,"%d",(int) ping_width); + (void) SetImageProperty(image,"PNG:IHDR.width ",msg); + + (void) FormatMagickString(msg,MaxTextExtent,"%d",(int) ping_height); + (void) SetImageProperty(image,"PNG:IHDR.height ",msg); + + (void) FormatMagickString(msg,MaxTextExtent,"%d",(int) ping_bit_depth); + (void) SetImageProperty(image,"PNG:IHDR.bit_depth ",msg); + + (void) FormatMagickString(msg,MaxTextExtent,"%d",(int) ping_color_type); + (void) SetImageProperty(image,"PNG:IHDR.color_type ",msg); + + (void) FormatMagickString(msg,MaxTextExtent,"%d", + (int) ping_interlace_method); + (void) SetImageProperty(image,"PNG:IHDR.interlace_method",msg); + +#endif + /* Read image scanlines. */ @@ -9657,6 +9685,7 @@ static MagickBooleanType WriteOnePNGImage(MngInfo *mng_info, value=GetImageProperty(image,property); if (ping_exclude_pHYs != MagickFalse || + LocaleNCompare(property,"png:",4) != 0 || LocaleCompare(property,"density") != 0 || LocaleCompare(property,"units") != 0) {