GraphicsMagick: WEBP: Add remove the expected APP1 Exif header t...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.2363.1680380885.1830.graphicsmagick-commit@lists.sourceforge.net> |
changeset da1c0cf93a98 in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=da1c0cf93a98 summary: WEBP: Add remove the expected APP1 Exif header to/from the Exif blob. diffstat: ChangeLog | 11 +++++++++++ Makefile.in | 1 + VisualMagick/installer/inc/version.isx | 4 ++-- coders/png.c | 24 +++++++++++------------- coders/webp.c | 28 +++++++++++++++++++++++++--- magick/Makefile.am | 1 + magick/profile-private.h | 13 +++++++++++++ magick/profile.c | 10 +++++----- magick/profile.h | 6 ++++++ magick/version.h | 4 ++-- www/Changelog.html | 11 +++++++++++ www/api/profile.html | 8 ++++---- 12 files changed, 92 insertions(+), 29 deletions(-) diffs (287 lines): diff -r 3f33eb4c4b92 -r da1c0cf93a98 ChangeLog --- a/ChangeLog Thu Mar 30 12:44:56 2023 -0500 +++ b/ChangeLog Sat Apr 01 15:27:53 2023 -0500 @@ -1,3 +1,14 @@ +2023-04-01 Bob Friesenhahn <[email protected]> + + * magick/profile-private.h: Added a new private implementation + header file. + + * coders/png.c: EXIF header implementation details/refinements. + + * coders/webp.c: Add/remove the internally expected 6-byte JPEG + APP1 "Exif\0\0" header to/from the pristine Exif blob. Addresses + SourceForge #696 "WebP Exif handling bug. + 2023-03-30 Bob Friesenhahn <[email protected]> * coders/jxl.c (ReadJXLImage): Fix JXL EXIF offset handling, and diff -r 3f33eb4c4b92 -r da1c0cf93a98 Makefile.in --- a/Makefile.in Thu Mar 30 12:44:56 2023 -0500 +++ b/Makefile.in Sat Apr 01 15:27:53 2023 -0500 @@ -4042,6 +4042,7 @@ magick/omp_data_view.h \ magick/pixel_cache-private.h \ magick/prefetch.h \ + magick/profile-private.h \ magick/random-private.h \ magick/registry-private.h \ magick/render-private.h \ diff -r 3f33eb4c4b92 -r da1c0cf93a98 VisualMagick/installer/inc/version.isx --- a/VisualMagick/installer/inc/version.isx Thu Mar 30 12:44:56 2023 -0500 +++ b/VisualMagick/installer/inc/version.isx Sat Apr 01 15:27:53 2023 -0500 @@ -10,5 +10,5 @@ #define public MagickPackageName "GraphicsMagick" #define public MagickPackageVersion "1.4" -#define public MagickPackageVersionAddendum ".020230330" -#define public MagickPackageReleaseDate "snapshot-20230330" +#define public MagickPackageVersionAddendum ".020230401" +#define public MagickPackageReleaseDate "snapshot-20230401" diff -r 3f33eb4c4b92 -r da1c0cf93a98 coders/png.c --- a/coders/png.c Thu Mar 30 12:44:56 2023 -0500 +++ b/coders/png.c Sat Apr 01 15:27:53 2023 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2022 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -1367,6 +1367,8 @@ size_t i; + const size_t app1_hdr_size = MAGICK_JPEG_APP1_EXIF_HEADER_SIZE; + image=(Image *) png_get_user_chunk_ptr(ping); if (image->logging) @@ -1384,26 +1386,22 @@ p=profile; - /* Stored profile must start with "Exif\0\0" */ - *p++ ='E'; - *p++ ='x'; - *p++ ='i'; - *p++ ='f'; - *p++ ='\0'; - *p++ ='\0'; + /* Stored profile should start with JPEG APP1 "Exif\0\0" header */ + (void) memcpy(p,MAGICK_JPEG_APP1_EXIF_HEADER,app1_hdr_size); + p += app1_hdr_size; i=0; s=chunk->data; - if (chunk->size > 6 && - (s[0] == 'E' && s[1] == 'x' && s[2] == 'i' && - s[3] == 'f' && s[4] == '\0' && s[5] == '\0')) + if (chunk->size > app1_hdr_size && + (memcmp((const void *) s,(const void *) MAGICK_JPEG_APP1_EXIF_HEADER, + app1_hdr_size) == 0)) { /* Skip over "Exif\0\0" if already present */ - i=6; - s += 6; + i=app1_hdr_size; + s += app1_hdr_size; } /* copy chunk->data to profile */ diff -r 3f33eb4c4b92 -r da1c0cf93a98 coders/webp.c --- a/coders/webp.c Thu Mar 30 12:44:56 2023 -0500 +++ b/coders/webp.c Sat Apr 01 15:27:53 2023 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2013-2022 GraphicsMagick Group +% Copyright (C) 2013-2023 GraphicsMagick Group % % This program is covered by multiple licenses, which are described in % Copyright.txt. You should have received a copy of Copyright.txt with this @@ -328,7 +328,17 @@ (void) LogMagickEvent(CoderEvent,GetMagickModule(),"EXIF Profile: %lu bytes", (unsigned long) flag_data.size); if ((flag_data.bytes != NULL) && (flag_data.size > 0)) - SetImageProfile(image,"EXIF",flag_data.bytes,flag_data.size); + + { + size_t profile_size = flag_data.size+MAGICK_JPEG_APP1_EXIF_HEADER_SIZE; + unsigned char *profile=MagickAllocateResourceLimitedMemory(unsigned char *,profile_size); + (void) memcpy((void *) profile, (const void *) MAGICK_JPEG_APP1_EXIF_HEADER, + MAGICK_JPEG_APP1_EXIF_HEADER_SIZE); + (void) memcpy((void *) (profile+MAGICK_JPEG_APP1_EXIF_HEADER_SIZE),flag_data.bytes, + flag_data.size); + SetImageProfile(image,"EXIF",profile,profile_size); + MagickFreeResourceLimitedMemory(profile); + } } if ((webp_flags & XMP_FLAG) && @@ -839,7 +849,7 @@ size_t idx; /* Mapping of GraphicsMagick->libwebp feature/profile names */ - char data_features[][3][6]={{"ICC", "ICCP"},{"EXIF", "EXIF"},{"XMP", "XMP"}}; + static const char data_features[][3][6]={{"ICC", "ICCP"},{"EXIF", "EXIF"},{"XMP", "XMP"}}; /* Prepare the WebP muxer */ WebPMuxError mux_error; @@ -860,6 +870,18 @@ if (!chunk.bytes) continue; + /* + Skip over JPEG APP1 "Exif\0\0" header if present + */ + if ((chunk.size > MAGICK_JPEG_APP1_EXIF_HEADER_SIZE) && + (memcmp((const void *) chunk.bytes, + (const void *) MAGICK_JPEG_APP1_EXIF_HEADER, + MAGICK_JPEG_APP1_EXIF_HEADER_SIZE) == 0)) + { + chunk.bytes += MAGICK_JPEG_APP1_EXIF_HEADER_SIZE; + chunk.size -= MAGICK_JPEG_APP1_EXIF_HEADER_SIZE; + } + /* Write feature data */ mux_error=WebPMuxSetChunk(mux,data_features[idx][1],&chunk,0); diff -r 3f33eb4c4b92 -r da1c0cf93a98 magick/Makefile.am --- a/magick/Makefile.am Thu Mar 30 12:44:56 2023 -0500 +++ b/magick/Makefile.am Sat Apr 01 15:27:53 2023 -0500 @@ -315,6 +315,7 @@ magick/omp_data_view.h \ magick/pixel_cache-private.h \ magick/prefetch.h \ + magick/profile-private.h \ magick/random-private.h \ magick/registry-private.h \ magick/render-private.h \ diff -r 3f33eb4c4b92 -r da1c0cf93a98 magick/profile-private.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/magick/profile-private.h Sat Apr 01 15:27:53 2023 -0500 @@ -0,0 +1,13 @@ +/* + Copyright (C) 2004 - 2023 GraphicsMagick Group + + This program is covered by multiple licenses, which are described in + Copyright.txt. You should have received a copy of Copyright.txt with this + package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. + + GraphicsMagick Private Methods For Manipulating Embedded Image Profiles. +*/ + +/* Header for JPEG APP1 EXIF profile */ +#define MAGICK_JPEG_APP1_EXIF_HEADER "Exif\0\0" +#define MAGICK_JPEG_APP1_EXIF_HEADER_SIZE (sizeof(MAGICK_JPEG_APP1_EXIF_HEADER)-1) diff -r 3f33eb4c4b92 -r da1c0cf93a98 magick/profile.c --- a/magick/profile.c Thu Mar 30 12:44:56 2023 -0500 +++ b/magick/profile.c Sat Apr 01 15:27:53 2023 -0500 @@ -1,5 +1,5 @@ /* -% Copyright (C) 2003-2021 GraphicsMagick Group +% Copyright (C) 2003-2023 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % Copyright 1991-1999 E. I. du Pont de Nemours and Company % @@ -272,8 +272,8 @@ % % o image: The image. % -% o name: Profile name. Valid names are "8BIM", "ICM", "IPTC", "XMP" or any -% unique text string. +% o name: Profile name. Valid names are "8BIM", "EXIF", "ICM", "IPTC", +% "XMP" or any unique text string. % % o length: Updated with profile length if profile is present. Set to NULL % if length is not needed. @@ -1202,8 +1202,8 @@ % % o image: The image. % -% o name: Profile name. Valid names are "8BIM", "ICM", "IPTC", XMP, or any -% unique text string. +% o name: Profile name. Valid names are "8BIM", EXIF, "ICM", "IPTC", +% XMP, or any unique text string. % % o profile: Address of profile to add. Pass zero to remove an existing % profile. diff -r 3f33eb4c4b92 -r da1c0cf93a98 magick/profile.h --- a/magick/profile.h Thu Mar 30 12:44:56 2023 -0500 +++ b/magick/profile.h Sat Apr 01 15:27:53 2023 -0500 @@ -75,6 +75,12 @@ extern MagickExport void DeallocateImageProfileIterator(ImageProfileIterator profile_iterator); +#if defined(MAGICK_IMPLEMENTATION) + +# include "magick/profile-private.h" + +#endif /* defined(MAGICK_IMPLEMENTATION) */ + #if defined(__cplusplus) || defined(c_plusplus) } #endif /* defined(__cplusplus) || defined(c_plusplus) */ diff -r 3f33eb4c4b92 -r da1c0cf93a98 magick/version.h --- a/magick/version.h Thu Mar 30 12:44:56 2023 -0500 +++ b/magick/version.h Sat Apr 01 15:27:53 2023 -0500 @@ -38,8 +38,8 @@ #define MagickLibVersion 0x272402 #define MagickLibVersionText "1.4" #define MagickLibVersionNumber 27,24,2 -#define MagickChangeDate "20230330" -#define MagickReleaseDate "snapshot-20230330" +#define MagickChangeDate "20230401" +#define MagickReleaseDate "snapshot-20230401" /* The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines diff -r 3f33eb4c4b92 -r da1c0cf93a98 www/Changelog.html --- a/www/Changelog.html Thu Mar 30 12:44:56 2023 -0500 +++ b/www/Changelog.html Sat Apr 01 15:27:53 2023 -0500 @@ -37,6 +37,17 @@ </div> <div class="document"> +<p>2023-04-01 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> +<blockquote> +<ul class="simple"> +<li><p>magick/profile-private.h: Added a new private implementation +header file.</p></li> +<li><p>coders/png.c: EXIF header implementation details/refinements.</p></li> +<li><p>coders/webp.c: Add/remove the internally expected 6-byte JPEG +APP1 "Exif00" header to/from the pristine Exif blob. Addresses +SourceForge #696 "WebP Exif handling bug.</p></li> +</ul> +</blockquote> <p>2023-03-30 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p> <blockquote> <ul class="simple"> diff -r 3f33eb4c4b92 -r da1c0cf93a98 www/api/profile.html --- a/www/api/profile.html Thu Mar 30 12:44:56 2023 -0500 +++ b/www/api/profile.html Sat Apr 01 15:27:53 2023 -0500 @@ -180,8 +180,8 @@ <dd><p>The image.</p> </dd> <dt>name:</dt> -<dd><p>Profile name. Valid names are "8BIM", "ICM", "IPTC", "XMP" or any -unique text string.</p> +<dd><p>Profile name. Valid names are "8BIM", "EXIF", "ICM", "IPTC", +"XMP" or any unique text string.</p> </dd> <dt>length:</dt> <dd><p>Updated with profile length if profile is present. Set to NULL @@ -297,8 +297,8 @@ <dd><p>The image.</p> </dd> <dt>name:</dt> -<dd><p>Profile name. Valid names are "8BIM", "ICM", "IPTC", XMP, or any -unique text string.</p> +<dd><p>Profile name. Valid names are "8BIM", EXIF, "ICM", "IPTC", +XMP, or any unique text string.</p> </dd> <dt>profile:</dt> <dd><p>Address of profile to add. Pass zero to remove an existing