ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: brendt on February 13, 2021, 06:43:06 PM

Title: TagsFromFile with -zip option
Post by: brendt on February 13, 2021, 06:43:06 PM
ExifTool is able to read tags from a bzip2 compressed TIFF file if the -z/-zip option is specified, but that option doesn't seem to work when using -TagsFromFile to copy tags from a compressed file to another file. Would it be possible to include support for this usage?
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 13, 2021, 09:24:47 PM
Interesting.  I hadn't considered this usage.  It could be a problem because expanding the .gz file is done by the application, but the -tagsFromFile feature is implemented by the underlying Image::ExifTool module.  Perhaps something like this would do what you need:

exiftool -z -X SRCFILE | exiftool -tagsfromfile - DSTFILE

This extracts the metadata in XML and uses this as input for writing.

- Phil
Title: Re: TagsFromFile with -zip option
Post by: brendt on February 14, 2021, 10:42:32 AM
Thanks for the suggestion. That seems to work, except that MakerNote tags (which I confirmed are included in the XML output of the first exiftool command) are not transferred into the destination file. Including "-all:all" or "-all:all -MakerNote" in the second exiftool command doesn't make any difference in this regard. Are there any other options here?
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 14, 2021, 12:46:10 PM
Makernotes tags may not be created individually, so you need to extract them as a block.  The -api makernotes option will do this, but you also need to add -b to extract as binary.  So try this:

exiftool -z -X -api makernotes -b SRCFILE | exiftool -tagsfromfile - DSTFILE

- Phil
Title: Re: TagsFromFile with -zip option
Post by: brendt on February 14, 2021, 01:45:31 PM
Thanks for the suggestion. Unfortunately it doesn't work. With those extra flags, the XMP includes a binary-encoded tag ExifIFD:MakerNoteNikon3, but the makernotes are not properly included in the destination file metadata, which includes a warning

Warning                         : [minor] Bad NikonScanIFD SubDirectory start
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 14, 2021, 03:09:29 PM
This should work.  What model of Nikon is it?

- Phil
Title: Re: TagsFromFile with -zip option
Post by: brendt on February 14, 2021, 05:04:29 PM
The MakerNotes are written by the NikonScan utility for Nikon Coolscan scanners.
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 14, 2021, 09:09:31 PM
OK.  Then I'll need a sample from you to be able to see what is happening.  If you can email one to me I'll take a look: philharvey66 at gmail.com

- Phil
Title: Re: TagsFromFile with -zip option
Post by: brendt on February 15, 2021, 10:29:07 AM
Thanks!

I've been trying to construct some small example images to email you (the originals are very large), but am having difficulty replicating the problem with the examples -- the suggested approach is only failing for the original images. At the moment I'm transferring the metadata from the original image to an example using

exiftool -tagsfromfile large_original.tif -all:all -makernote -b small_example.tif

but the output of exiftool -X -api makernotes -b is different for these two files, and the problem does not occur when using small_example.tif as the source image for the metadata copy. Is there some more complete way of copying the metadata from large_original.tif to small_example.tif?
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 15, 2021, 04:52:22 PM
I got your small example that gave a runtime error, and will patch ExifTool to include a test to avoid this runtime problem.

But I think I need the original to figure out why the makernotes aren't being copied.  If it is too large for email, could you upload it somewhere?

- Phil
Title: Re: TagsFromFile with -zip option
Post by: brendt on February 15, 2021, 05:59:34 PM
Will do.
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 15, 2021, 09:32:23 PM
I got the sample, thanks.  It seems that ExifTool is not rebuilding the NikonScanIFD properly when copying the Nikon MakerNotes from this TIFF file.  I'll look into this.

- Phil
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 18, 2021, 07:50:31 PM
This was difficult.  I have fixed a couple of issues (related to the fact that the NikonScanIFD runs past the end of the makernotes block in the original file), but the NikonScanIFD still can't be preserved through the XML format.  However, with the most recent version of ExifTool (12.19), you can do this:

gzip -dc SRCFILE.gz | exiftool -tagsfromfile -all:all -api makernotes DSTFILE

- Phil

Title: Re: TagsFromFile with -zip option
Post by: brendt on February 20, 2021, 03:53:53 PM
Thanks for your help with this! So the problem boils down to NikonScan writing the tags in a way that breaks the TIFF format?

Using

gzip -dc SRCFILE.gz | exiftool -tagsfromfile -all:all -api makernotes DSTFILE

is a reasonable solution, but it does require uncompressing the entire source file. My impression has been that exiftool -z only uncompresses enough of it to read the metadata, but perhaps that's not actually the case?
Title: Re: TagsFromFile with -zip option
Post by: Phil Harvey on February 20, 2021, 10:40:34 PM
Quote from: brendt on February 20, 2021, 03:53:53 PM
So the problem boils down to NikonScan writing the tags in a way that breaks the TIFF format?

Basically, yes.

QuoteMy impression has been that exiftool -z only uncompresses enough of it to read the metadata

Sometimes this is true (ie. If there is no indication that the file has a trailer containing metadata), but in general you should add -fast if you don't want ExifTool to check for trailer information.

- Phil