GraphicsMagick: coders/tiff.c Do not call TIFFWriteDirectory, TI...

GraphicsMagick Commits <[email protected]> Fri, 12 Jan 2024 02:22:24 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.2207.1705047756.19238.graphicsmagick-commit@lists.sourceforge.net>
changeset f37c7cff863f in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=f37c7cff863f
summary: coders/tiff.c Do not call TIFFWriteDirectory, TIFFSetDirectory and TIFFCreateDirectory for the latest frame. It cuts EXIF tags from unknown reason.

diffstat:

 coders/tiff.c |  33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diffs (58 lines):

diff -r ffe41af4b7c9 -r f37c7cff863f coders/tiff.c
--- a/coders/tiff.c	Fri Jan 12 03:12:11 2024 +0100
+++ b/coders/tiff.c	Fri Jan 12 09:22:03 2024 +0100
@@ -4492,7 +4492,7 @@
       Value = LD_UINT32(IFD_data+8);
 
       fip = TIFFFindField(tiff, Tag, TIFF_ANY);
-      if(logging)
+      if(logging && (Flags & FLAG_BASE)!=0)
         (void)LogMagickEvent(CoderEvent,GetMagickModule(),"Extracted tag from EXIF %xh, Field %d, Long2 %d, val %d %s",
                            Tag, Field, Long2, Value, FipFieldName(fip));
 
@@ -4517,7 +4517,7 @@
         goto NextItem;
       }
 
-      if(fip!=NULL && (Flags & FLAG_BASE)!= 0)		/* libtiff doesn't understand these */
+      if(fip!=NULL && (Flags & FLAG_BASE)!=0)		/* libtiff doesn't understand these */
       {
         const TIFFDataType FDT = TIFFFieldDataType(fip);
         const int WriteCount = TIFFFieldWriteCount(fip);
@@ -6756,20 +6756,23 @@
             }
 */
                 /* Save changed tiff-directory to file */
-            if(!TIFFWriteDirectory(tiff))
-            {
-              (void)LogMagickEvent(CoderEvent, GetMagickModule(), "TIFFWriteDirectory returns failed status!");
-            }
-              // Re configure directory status for next image. Reset current IFD number.
-            if(!TIFFSetDirectory(tiff, current_mainifd))
+            if(image->next != (Image *)NULL)
             {
-              if(logging)
-                LogMagickEvent(CoderEvent,GetMagickModule(),"TIFFSetDirectory() failed.\n");
-            }
-            if(!TIFFCreateDirectory(tiff))
-            {
-              if(logging)
-                LogMagickEvent(CoderEvent,GetMagickModule(),"TIFFCreateDirectory() failed.\n");
+              if(!TIFFWriteDirectory(tiff))
+              {
+                (void)LogMagickEvent(CoderEvent, GetMagickModule(), "TIFFWriteDirectory returns failed status!");
+              }
+              // Re configure directory status for next image. Reset current IFD number.
+              if(!TIFFSetDirectory(tiff, current_mainifd))
+              {
+                if(logging)
+                  LogMagickEvent(CoderEvent,GetMagickModule(),"TIFFSetDirectory() failed.\n");
+              }
+              if(!TIFFCreateDirectory(tiff))
+              {
+                if(logging)
+                  LogMagickEvent(CoderEvent,GetMagickModule(),"TIFFCreateDirectory() failed.\n");
+              }
             }
           }
         }