In my application, I want to run the XMP2IPTC and XMP2EXIF arg files only when the target file already has IIM IPTC or EXIF metadata. Is there a reliable way to tell if a file has IPTC/EXIF data?
My first idea was to check for the mandatory EXIF version tag. But that was not fruitful because I found many files without this tag. For IPTC, I checked for the IPTC record version, which seemed to work well. But then I found files produced/modified by DAMinion and/or idimager, and these files had not IPTC record version although they contained IPTC tags like headline and caption-abstract.
Since I cache the output of ExifTool in a database, the ideal solution would be a lookup to check the existence of one or more tags to determine if the XMP2... arg files need to be run.
The only other idea I had so far would be to use the block tags -iptc and -exif (without -b) and to parse the output to see if these tags are included in the output. But I think this may be a performance hit (my application processes tens of thousands of files) and I would have to reload the metadata of all files already processed.
Any ideas appreciated.
Quote from: Mac2 on November 27, 2013, 02:10:47 AM
Is there a reliable way to tell if a file has IPTC/EXIF data?
Use
-if "$exif:all" to only process files containing EXIF data. You can do the same for IPTC.
But if you want to just check the extracted tags, you will have to extract with
-G -a and look for any EXIF or IPTC tags.
QuoteThe only other idea I had so far would be to use the block tags -iptc and -exif (without -b) and to parse the output to see if these tags are included in the output. But I think this may be a performance hit (my application processes tens of thousands of files) and I would have to reload the metadata of all files already processed.
This would work too. I would expect the performance hit to be minimal.
- Phil
Hi, Phil
My application imports all metadata and runs ...2XMP.args files to produce rich XMP data before caching the result. Hence I cannot skip files as you suggested. Sorry to be not more clear in my question.
I need to find a way to tell after the import (from the database contents) if a file had IPTC/EXIF on import. At the time my application produces the ARG file to instruct ExifTool what to write, I include a call to the XMP2IPTC.ARG file to ensure MWG compliance (if the output file format supports IPTC):
...
-@
xmp2iptc.args
...
Could I use the -if logic here as well, to test for existing IPTC data in the output file and only then run the XMP2IPTC arg file?
I guess I don't understand. The -if option can be used with any command.
- Phil
I'm looking for something like
-xmp:descrioption=value
...
-if
$iptc:all
-@
xmp2iptc.args
output.jpg
Basically a way to tell ExifTool in an argfile to run xmp2iptc.arg only when the file has IPTC. I think -if can only be used to skip files based on a condition, but I want to write the XMP data and only run the xmp2iptc.arg file conditionally. Not sure if this is possible at all or if I have to implement this in my app.
If you want to always write some tags, but conditionally do something else, you need to execute a separate command, like this:
-xmp:description=value
...
-execute
-if
$iptc:all
-@
xmp2iptc.args
-common_args
output.jpg
- Phil
Pardon the intrusion, but doesn't that last example contradict the documentation?
"-common_args
Specifies that all arguments following this option are common to all executed commands when -execute is used. This and the -config option are the only options that may not be used inside a -@ ARGFILE. Note that by definition this option and its arguments MUST come after all other options on the command line."
Jim
Quote from: ryerman on November 30, 2013, 11:05:18 AM
Pardon the intrusion, but doesn't that last example contradict the documentation?
Woops! My bad. Good catch Jim. :)
- Phil
Quote from: Phil Harvey on November 30, 2013, 07:06:19 AM
If you want to always write some tags, but conditionally do something else, you need to execute a separate command, like this:
I understand, thanks. This would work.
But as I understand it, each execute causes ExifTool to reprocess the entire file (read/write). For typical RAW file sizes of 10 and 50 MB, or PSD/TIFF of usually 100 to 500 MB, this would probably cause performance problems. I will handle this in my application then. I know up-front and can pack everything into one execute for ExifTool.