perl syntax to inject external XMP data into image files?

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

Previous topic - Next topic

Archive

[Originally posted by stainsby on 2008-04-24 17:13:10-07]

I found Phil's example from 2005 and have commandline syntax working just fine.
Code:
  exiftool -xmp'<=../xmp/external.xmp' -o ./test/%f.%e .
When I fire ImageInfo I get exactly what I need to see.

However, I cannot for the life of me see how to specify the exquivalent behaviour in the perl scripts I am setting up.  My current guess runs something like this:
Code:
  my $exif = Image::ExifTool->new();
   $exif->SetNewValuesFromFile( $xmpfn, 'XMP:*' );
   $exif->WriteInfo( $fn );   
Clarification? Anyone?
Erik

Archive

[Originally posted by exiftool on 2008-04-24 17:29:35-07]

Hi Erik,

Your script will copy the tags individually from the
XMP file, but the command line set the value of the
"XMP" tag from the data of the file.  ie)

Code:
  my $exif = Image::ExifTool->new();
   my $data;
   open FILE, $xmpfn or die;
   read FILE, $data, 1000000 or die;
   close FILE;
   $exif->SetNewValue( 'XMP', $data );
   $exif->WriteInfo( $fn );   

Of course, this code imposes an arbitrary restriction
of 1000000 bytes on the size of the XMP file -- this was
done just to simplify the example.

- Phil

Archive

[Originally posted by exiftool on 2008-04-24 17:34:54-07]

Also, I should mention that

Code:
  -o ./test/%f.%e

is equivalent to

Code:
  -o test

provided the "test" directory already exists.

- Phil

Archive

[Originally posted by exiftool on 2008-04-24 17:37:58-07]

I just read my own documentation and realized
that

Code:
  -o test/

(with the trailing slash) is equivalent to what you have done, even
if the test directory doesn't already exist.  (ie. the "test" directory
will be created.)

- Phil

Archive

[Originally posted by stainsby on 2008-04-24 20:13:15-07]

Exactly what was needed. Thanks, Phil, and thanks so much for the great tool.