GraphicsMagick: coders/tiff.c Improved optional log record.

GraphicsMagick Commits <[email protected]> Sun, 17 Dec 2023 06:32:02 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.13416.1702816335.7794.graphicsmagick-commit@lists.sourceforge.net>
changeset 6cb77a06d0ad in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=6cb77a06d0ad
summary: coders/tiff.c Improved optional log record.

diffstat:

 ChangeLog     |   2 ++
 coders/tiff.c |  18 ++++++++++--------
 2 files changed, 12 insertions(+), 8 deletions(-)

diffs (62 lines):

diff -r 9a403d97bcda -r 6cb77a06d0ad ChangeLog
--- a/ChangeLog	Sun Dec 17 11:37:18 2023 +0100
+++ b/ChangeLog	Sun Dec 17 13:31:26 2023 +0100
@@ -1,6 +1,8 @@
 2023-12-16  Fojtik Jaroslav  <[email protected]>
 
 	* coders/tiff.c Check recipe compatibility for TIFFSetField().
+	Improved optional log record:
+	Extracted tag from EXIF 213h, Field 3, Long2 1, val 2 YCbCrPositioning
 
 2023-12-16  Fojtik Jaroslav  <[email protected]>
 
diff -r 9a403d97bcda -r 6cb77a06d0ad coders/tiff.c
--- a/coders/tiff.c	Sun Dec 17 11:37:18 2023 +0100
+++ b/coders/tiff.c	Sun Dec 17 13:31:26 2023 +0100
@@ -4448,8 +4448,7 @@
 int FieldCount = 0;
 uint32_t(*LD_UINT32)(const unsigned char *Mem);
 uint16_t(*LD_UINT16)(const unsigned char *Mem);
-const TIFFField *fip;  // = TIFFFindField(tif, tag, TIFF_ANY);
-/* TIFFField FakeField; */
+const TIFFField *fip;
 
   if(profile_data==NULL || profile_length<12+8) return 0;
   if(memcmp(EXIF,profile_data,6)==0)
@@ -4497,15 +4496,18 @@
       Field = LD_UINT16(profile_data+IFDpos+2);
       Long2 = LD_UINT32(profile_data+IFDpos+4);
       Value = LD_UINT32(profile_data+IFDpos+8);
+      fip = TIFFFindField(tiff, Tag, TIFF_ANY);
+
       if(logging)
-        (void)LogMagickEvent(CoderEvent,GetMagickModule(),"Extracted tag from EXIF %xh, Field %d, Long2 %d, val %d", Tag, Field, Long2, Value);
-
-      fip = TIFFFindField(tiff, Tag, TIFF_ANY);
+        (void)LogMagickEvent(CoderEvent,GetMagickModule(),"Extracted tag from EXIF %xh, Field %d, Long2 %d, val %d %s",
+                             Tag, Field, Long2, Value, (fip!=NULL)?fip->field_name:"UNSUPPORTED");
+
       if(fip!=NULL)		/* libtiff doesn't understand these */
       {
         switch(Field)
         {
-          case TIFF_ASCII: if(fip->field_type!=TIFF_ASCII) break;	/* Incompatible recipe.*/
+          case TIFF_ASCII: if(fip->field_type!=TIFF_ASCII)
+                               break;	/* Incompatible recipe.*/
                            if(Value>=profile_length-1) break;		/* String outside EXIF boundary. */
                            if(TIFFSetField(tiff, Tag, profile_data+Value))
                                FieldCount++;
@@ -6634,11 +6636,11 @@
               {  // Go back to the first directory, and add the EXIFIFD pointer.
                 TIFFSetDirectory(tiff, 0);
                 TIFFSetField(tiff, TIFFTAG_EXIFIFD, dir_offset);
-                if(!TIFFWriteDirectory(tiff))
+                /*if(!TIFFWriteDirectory(tiff))  This destroys part of EXIF from unknown reason, commented out.
                 {
                  (void)LogMagickEvent(CoderEvent,GetMagickModule(),
                                 "TIFFWriteDirectory EXIF returns failed status!");
-                }
+                }*/
               }
             }
           }