From 815fc1e110a7adf7428a1cc46b9acd5827848d1c Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 27 Feb 2025 19:02:33 -0800 Subject: [PATCH 1/3] pngdec.c: add missing #ifdef for png_get_iCCP png_get_iCCP is an optional part of the API. Protect its usage with PNG_iCCP_SUPPORTED. Change-Id: I1ac777d1c2a200bb3e1303b3d095cc0d67633bd4 --- imageio/pngdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imageio/pngdec.c b/imageio/pngdec.c index cdd99883..f63cbebc 100644 --- a/imageio/pngdec.c +++ b/imageio/pngdec.c @@ -192,6 +192,7 @@ static int ExtractMetadataFromPNG(png_structp png, } } } +#ifdef PNG_iCCP_SUPPORTED // Look for an ICC profile. { png_charp name; @@ -208,6 +209,7 @@ static int ExtractMetadataFromPNG(png_structp png, if (!MetadataCopy((const char*)profile, len, &metadata->iccp)) return 0; } } +#endif // PNG_iCCP_SUPPORTED } return 1; } From 319860e919d5fcce13a3bebe77dcff88abbc78d5 Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 27 Feb 2025 19:09:28 -0800 Subject: [PATCH 2/3] pngdec.c: support ImageMagick app1 exif text data Test file created with ImageMagick 6.9.13-12: ``` convert test_exif.png test_app1_exif.png ``` Bug: webp:398066379 Change-Id: I10a20de5699fabb0906045994d7d1f4b9e951973 --- imageio/pngdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/imageio/pngdec.c b/imageio/pngdec.c index f63cbebc..8dc3c6c7 100644 --- a/imageio/pngdec.c +++ b/imageio/pngdec.c @@ -139,6 +139,8 @@ static const struct { { "Raw profile type xmp", ProcessRawProfile, METADATA_OFFSET(xmp) }, // Exiftool puts exif data in APP1 chunk, too. { "Raw profile type APP1", ProcessRawProfile, METADATA_OFFSET(exif) }, + // ImageMagick uses lowercase app1. + { "Raw profile type app1", ProcessRawProfile, METADATA_OFFSET(exif) }, // XMP Specification Part 3, Section 3 #PNG { "XML:com.adobe.xmp", MetadataCopy, METADATA_OFFSET(xmp) }, { NULL, NULL, 0 }, From 565da148829ce8ad951baf5190b2b718d6ee35c0 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 28 Feb 2025 12:53:41 -0800 Subject: [PATCH 3/3] pngdec.c: add support for 'eXIf' tag Test file created with exiftool 12.76: ``` exiftool test_app1_exif.png -exif:all \ -exif:DocumentName=test_multi_exif.png -o test_multi_exif.png ``` Bug: webp:398066379 Change-Id: I1437390a70f5708421683eb69c588624bb376baa --- imageio/pngdec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/imageio/pngdec.c b/imageio/pngdec.c index 8dc3c6c7..049acd7c 100644 --- a/imageio/pngdec.c +++ b/imageio/pngdec.c @@ -161,6 +161,20 @@ static int ExtractMetadataFromPNG(png_structp png, png_textp text = NULL; const png_uint_32 num = png_get_text(png, info, &text, NULL); png_uint_32 i; + +#ifdef PNG_eXIf_SUPPORTED + // Look for an 'eXIf' tag. Preference is given to this tag as it's newer + // than the TextualData tags. + { + png_bytep exif; + png_uint_32 len; + + if (png_get_eXIf_1(png, info, &len, &exif) == PNG_INFO_eXIf) { + if (!MetadataCopy((const char*)exif, len, &metadata->exif)) return 0; + } + } +#endif // PNG_eXIf_SUPPORTED + // Look for EXIF / XMP metadata. for (i = 0; i < num; ++i, ++text) { int j;