2023.12.20 22:06 "[Tiff] EXIF tag writing fails starting with libtiff 4.5.1?", by Bob Friesenhahn

2023.12.20 22:06 "[Tiff] EXIF tag writing fails starting with libtiff 4.5.1?", by Bob Friesenhahn

Recently a volunteer submitted code to GraphicsMagick's TIFF writer to create an EXIF subifd. When I tested this, it did not work for me. I was using latest libtiff from git.

I did some investigating and found that the code works for libtiff 4.4.0 and 4.5.0 but fails starting with 4.5.1. Is anyone aware of changes which might cause the issue (or detect a problem which was not detected before)?

The test case writes three identical images in order, each with an identical EXIF IFD.

The final errors reported are:

15:49:49 0:0.005317  0.000u 2345878 tiff.c/AddExifFields/4510/Coder:
   Extracted tag from EXIF 11ah, Field 5, Long2 1, val 17895 XResolution
15:49:49 0:0.005443  0.000u 2345878 tiff.c/TIFFWriteErrors/975/Coder:
   Ignored: Error fetching directory link. (TIFFRewriteDirectory)
15:49:49 0:0.005476  0.000u 2345878 tiff.c/TIFFWriteErrors/975/Coder:
   Ignored: Error fetching directory link. (TIFFRewriteDirectory)
15:49:49 0:0.006473  0.000u 2345878 tiff.c/WriteTIFFImage/6687/Coder:
   Removed broken output file "input_truecolor.tiff"
15:49:49 0:0.006495  0.000u 2345878
constitute.c/WriteImage/2325/Coder:  Returned from "TIFF" encoder, Failed
./utilities/gm convert: TIFF directory is missing required "ImageLength" field. (MissingRequired).

Bob

Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt