ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: thinbegin on March 14, 2025, 05:36:02 PM

Title: TIF file bad ExifIFD won't update
Post by: thinbegin on March 14, 2025, 05:36:02 PM
getting the following error when trying to write to a TIF file that was generated from a scanner (Microtek M1)

Error: Bad format (0) for ExifIFD entry 0
0 image files updated
1 files weren't updated due to errors

I did some searching of the forum and found similar issues, and the suggestion that passing the "-m" flag might force the update, but that didn't work either (got the same error as shown above).

Thoughts?

More details:
exiftool version: 13.25
System OS: MacOS 11.6.3 (Big Sur)
The image file is viewable in Preview.app and Adobe Lightroom 5.7
Title: Re: TIF file bad ExifIFD won't update
Post by: StarGeek on March 14, 2025, 05:45:21 PM
Is this file directly from the scanner? Or has some other software been used on the file? Can you share the file?

Can you open the image for viewing?

If I recall correctly, this isn't something exiftool can deal with easily. You might try running the command in FAQ #20 (https://exiftool.org/faq.html#Q20) on a copy of the file to see if that works (not on the original), but that has a good chance of breaking the file.

If the image can be viewed, you might try loading and resaving it.
Title: Re: TIF file bad ExifIFD won't update
Post by: thinbegin on March 14, 2025, 08:15:54 PM
Yes it is directly from the scanner (no intermediary involved), and yes it is viewable.  I'd be happy to share the file, but this WYSIWYG doesn't seem to let me.

I added a little more info to my main post (added there so it doesn't get lost in the comments)
Title: Re: TIF file bad ExifIFD won't update
Post by: StarGeek on March 14, 2025, 08:47:52 PM
Quote from: thinbegin on March 14, 2025, 08:15:54 PMI'd be happy to share the file, but this WYSIWYG doesn't seem to let me.

Hit the "Reply" button and there will be a "click or drag" button at the bottom of the text box. See here (https://exiftool.org/forum/index.php?msg=87312).

Or you can link it from something like Dropbox/Google Drive.

If it's directly from the scanner, Phil might want to take a look at it.
Title: Re: TIF file bad ExifIFD won't update
Post by: Phil Harvey on March 14, 2025, 09:37:53 PM
I can take a look at it, but I don't think that ExifTool will allow you to write this file.

- Phil
Title: Re: TIF file bad ExifIFD won't update
Post by: thinbegin on March 15, 2025, 12:04:07 AM
"File too big"... won't let me upload unfortunately.

Here's a link to it from my DropBox though:
https://www.dropbox.com/scl/fi/qbkelfwiu9yetjjxtq5qj/Sheet-008-03.tif?rlkey=wibcnyv3g6twzo4u4tvz4nzqa&dl=0
Title: Re: TIF file bad ExifIFD won't update
Post by: thinbegin on March 15, 2025, 12:04:39 AM
Quote from: Phil Harvey on March 14, 2025, 09:37:53 PMI can take a look at it, but I don't think that ExifTool will allow you to write this file.

- Phil

Why do you think that might be?
Title: Re: TIF file bad ExifIFD won't update
Post by: StarGeek on March 15, 2025, 01:26:04 AM
I used Irfanview to resave the image. It's slightly smaller due to LZW lossless compression.

See if this copy (https://www.dropbox.com/scl/fi/anankizi9fp7r1lo8vxih/Sheet-008-03-resave.tif?rlkey=bprf0zk6fii21vvfrus4emmzq&st=9oxthezs&dl=0) works for you. I was able to edit it with exiftool.

I'm actually a bit impressed that Irfanview saved both pages. The IPTC data wasn't copied over to the resaved version, but that can be fixed with exiftool.

There is also an unknown tag, MakerNoteUnknownBinary, that didn't get copied over.
Title: Re: TIF file bad ExifIFD won't update
Post by: thinbegin on March 15, 2025, 01:43:14 AM
Thank you for this.

Quote from: StarGeek on March 15, 2025, 01:26:04 AMI used Irfanview to resave the image. It's slightly smaller due to LZW lossless compression.

Slightly smaller? 33% smaller (which is quite a bit really).

That isn't really a workable solution long-term though. I would really like to understand why the original file's issue was, and see if that can't be directly addressed.  Any thoughts?

Oh, and worth mentioning that the command in FAQ #20 did actually work! (Which is weird because that FAQ also goes on to say, "Also, ExifTool may not be used like this to repair TIFF-based files or RAW files")
Is that a clue to anything useful?
exiftool -all= -tagsfromfile @ -all:all -unsafe -icc_profile Sheet-007-03\ copy.tif
Warning: Bad format (6660) for ExifIFD entry 0 - Sheet-007-03 copy.tif
Warning: [minor] Can't delete IFD0 from TIFF - Sheet-007-03 copy.tif
    1 image files updated
Title: Re: TIF file bad ExifIFD won't update
Post by: Phil Harvey on March 15, 2025, 08:45:36 AM
Yes.  To my surprise FAQ 20 does work on this image.  The reason is that the corruption was luckily limited to the ExifIFD.

The ExifIFD in IFD0 of this TIFF file was OK, but IFD1 also contained an ExifIFD with a bad pointer (it is missing the upper 16 bits).  I can see where this extra ExifIFD is, and it contains only the width/height of the IFD1 image, so it isn't a big deal that this gets deleted with the FAQ 20 command.

- Phil
Title: Re: TIF file bad ExifIFD won't update
Post by: StarGeek on March 15, 2025, 11:11:10 AM
Quote from: thinbegin on March 15, 2025, 01:43:14 AMSlightly smaller? 33% smaller (which is quite a bit really).

True that.

Using ImageMagick 7, the gold standard FOSS command line image manipulation program, with this command
magick Y:\!temp\x\y\Sheet-008-03.tif -compress lzw Y:\!temp\x\y\Sheet-008-03-LZWCompress.tif

Gives even better results, with Zip compression giving the smallest file size.
C:\>exiftool -G1 -a -s -filesize Y:\!temp\x\y\Sheet-008-03*
======== Y:/!temp/x/y/Sheet-008-03-IrfanViewLZW.tif
[System]        FileSize                        : 26 MB
======== Y:/!temp/x/y/Sheet-008-03-LZWCompress.tif
[System]        FileSize                        : 20 MB
======== Y:/!temp/x/y/Sheet-008-03-ZipCompress.tif
[System]        FileSize                        : 19 MB
======== Y:/!temp/x/y/Sheet-008-03.tif
[System]        FileSize                        : 37 MB

But it doesn't copy the metadata and throws a lot of warnings.
Title: Re: TIF file bad ExifIFD won't update
Post by: thinbegin on March 15, 2025, 01:31:06 PM
@Phil, given what you've seen with this file, do you think there's some sort of fix that could be done so that I can skip that intermediary (FAQ #20) step for other files made by the same scanning software?
Title: Re: TIF file bad ExifIFD won't update
Post by: Phil Harvey on March 15, 2025, 03:18:46 PM
You can combine the FAQ #20 step with whatever you were trying to write in the first place.

- Phil