Thread

Posted on Thu Apr 24 20:13:10 2008 by stainsby
perl syntax to inject external XMP data into image files?
I found Phil's example from 2005 and have commandline syntax working just fine.
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:
my $exif = Image::ExifTool->new(); $exif->SetNewValuesFromFile( $xmpfn, 'XMP:*' ); $exif->WriteInfo( $fn );
Clarification? Anyone? Erik
Direct Responses: 7757 | Write a response
Posted on Thu Apr 24 20:29:35 2008 by exiftool in response to 7756
Re: perl syntax to inject external XMP data into image files?
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)

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
Direct Responses: 7758 | 7763 | Write a response
Posted on Thu Apr 24 20:34:54 2008 by exiftool in response to 7757
Re: perl syntax to inject external XMP data into image files?
Also, I should mention that

-o ./test/%f.%e

is equivalent to

-o test

provided the "test" directory already exists.

- Phil
Direct Responses: 7759 | Write a response
Posted on Thu Apr 24 20:37:58 2008 by exiftool in response to 7758
Re: perl syntax to inject external XMP data into image files?
I just read my own documentation and realized that

-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
Write a response
Posted on Thu Apr 24 23:13:15 2008 by stainsby in response to 7757
Re: perl syntax to inject external XMP data into image files?
Exactly what was needed. Thanks, Phil, and thanks so much for the great tool.
Write a response