TIF file bad ExifIFD won't update

Started by thinbegin, March 14, 2025, 05:36:02 PM

Previous topic - Next topic

thinbegin

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

StarGeek

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 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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

thinbegin

#2
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)

StarGeek

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.

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

I can take a look at it, but I don't think that ExifTool will allow you to write this file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

thinbegin

"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

thinbegin

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?

StarGeek

I used Irfanview to resave the image. It's slightly smaller due to LZW lossless compression.

See if this copy 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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

thinbegin

#8
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

Phil Harvey

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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

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.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

thinbegin

@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?

Phil Harvey

You can combine the FAQ #20 step with whatever you were trying to write in the first place.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).