adding tags to TIF, whole file ready?

Started by pmh4514, September 14, 2016, 05:13:08 PM

Previous topic - Next topic

pmh4514

Hello,
If I run this command:

exiftool -xresolution=20.34 -yresolution=20.34 -resolutionunit=cm c:\local\big.tif -overwrite_original_in_place

and big.tif is a very large file (1GB+), what's happening "under the hood"? Does it have to read the whole file, write a new one and delete the old? Or does it inject the tags directly into the header.

I'm considering using exiftool as a process in my own software application, but my application would likely be creating and saving new images while exiftool was running in batch as a process.. I worry about the hard-drive access ramifications of doing so. 

Thanks for any insights

Phil Harvey

#1
Quote from: pmh4514 on September 14, 2016, 05:13:08 PM
Does it have to read the whole file, write a new one and delete the old?

Yes.

From the description of -overwrite_original in the application documentation:

            The overwrite is implemented by renaming a temporary file to replace the original.

But I just noticed you are using -overwrite_original_in_place, which says:

            This is implemented by opening the original file
            in update mode and replacing its data with a copy of a temporary
            file before deleting the temporary.  The extra step results in
            slower performance, so the -overwrite_original option should be
            used instead unless necessary.


So you can speed things up by using -overwrite_original instead of -overwrite_original_in_place.

- Phil

Edit: Added quotes from the documentation.
...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 ($).

pmh4514

Thanks Phil.
You're the author of this tool? Very nice work!

My big concern is bottlenecks.. If I have a process that is writing out lots of files, to have another process have to read each in, add the meta-data, save out a new copy and delete the old, all in parallel with the other process which is creating the images, that could lead to performance issues I think.  Was hoping there'd be a way to "inject" tag data into the header without having to do all that disc access.

Probably better I try to get access to the original code that's creating the TIFF files in the first place and modify that to add the headers at write-time.




Phil Harvey

Good idea.

Either that, or pipe it through ExifTool before it gets written to disk:

utility_to_generate_tiff -o - | exiftool - -TAG=VALUE ... > out.tif

But the overhead of launching exiftool for each image using this technique would be significant, and using the -stay_open feature is difficult with pipes.

- 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 ($).

pmh4514