Files chosen for -TagsfromFile in arg file?

Started by Archive, May 12, 2010, 08:53:54 AM

Previous topic - Next topic

Archive

[Originally posted by delenca on 2006-05-05 13:56:15-07]

  Some recently written front-end scripts for Exiftool in IMatch process multiple files by executing a separate instance of exiftool for each file.

  I was wondering if it might be more efficient to have IMatch generate a list of all source, target files to a .arg file and then execute ExifTool _once_ using that .arg file as an argument.

  Would that work? Would it actually be more efficient (i.e. faster?)

  Thanks,

  Alex

Archive

[Originally posted by exiftool on 2006-05-05 14:35:53-07]

ExifTool is much more efficient when processing multiple files, for 2 reasons:

1) The Perl interpreter only has to be launched once, and the ExifTool Perl code only has to be compiled once.

2) If a common set of tags are written to each file, the source file (if used) only has to be read once, and the tag values only have to be set once.

So you should process multiple files together if at all possible.  If processing a large number of images, the time savings could be substantial.

The command-line interface allows you to process multiple files at once, but only if similar actions are performed on each file.

Archive

[Originally posted by delenca on 2006-05-05 19:46:06-07]

Great. That's what I thought.

I've looked at the iptc2xmp.args example you provide but I still have some questions about how to implement it in an IMatch script.

Basically, I imagine collecting the source and target images via IMatch and have them written to an appropriate .args file. But what should the format be? (the goal is to copy all exif metadata from, usually, a .THM or .CRW to a .jpg).

invoke exiftool with: exiftool -@ file.args ?

then file.args is:

-overwrite_original -TagsFromFile x.CRW -Orientation=Normal x.jpg

-overwrite_original -TagsFromFile y.CRW -Orientation=Normal y.jpg

etc...

Is that correct, or how would you do it?

Thanks,

Alex

Archive

[Originally posted by exiftool on 2006-05-06 14:00:37-07]

Not quite.  It is all still a single command, so what you wrote won't work.  (It will take tags from x.CRW and y.CRW and write them to x.jpg and y.jpg).  Also, with the -@ file, you must specify only one argument per line.

So instead, you need to do something like this in file.args:

Code:
-overwrite_original
-tagsfromfile
%d%f.CRW
-orientation=Normal
x.jpg
y.jpg
etc...

Hopefully this makes a bit of sense.

Archive

[Originally posted by delenca on 2006-05-06 19:03:32-07]

Hmm, pity. In that case I don't think I can do what I had in mind. I wanted to use Imatch to generate my list of matches and then send those to Exiftool already in x.crw, whatever.jpg pairs. Note that my question was a little misleading. The name of the crw file and the jpg file may not necessarily match. So I wanted to use other IMatch scripts that I have to generate the matches and then have them sent as pairs and processed by Exiftool. But it doesn't look like the args file works that way. I too hope this made sense!

-Alex

Archive

[Originally posted by exiftool on 2006-05-07 11:41:44-07]

Hi Alex,

Yes, there are some limitations in the 'exiftool' interface.  However, it is simple to overcome any of these limitations by using the ExifTool module and writing a bit of Perl yourself.  The following Perl script will do the same thing, but supports arbitrary filenames.  Really pretty simple to do:

Code:
#!/usr/bin/perl -w
use strict;
push @INC, 'path_for_exiftool_lib_directory';
require Image::ExifTool;

my %files = (
    'a.jpg' => 'a.CRW',
    'b.jpg' => 'b.CRW',
);

my $jpg;
foreach $jpg (keys %files) {
    my $exifTool = new Image::ExifTool;
    $exifTool->SetNewValuesFromFile($files{$jpg});
    $exifTool->SetNewValue(Orientation => 'Normal');
    $exifTool->WriteInfo($jpg);
    my $err = $exifTool->GetValue('Error');
    $err and warn "Error writing '$jpg': $err\n";
}
# end