Posted on 2010-02-06 21:01:21.389259-08 by dschless
XMP to IPTC Keywords

I have a JPG image with the following XMP information. Is it possible to copy the two Region Person Display Name values (note one of the values contains a comma) to the IPTC:Keywords field using exiftool?

Thanks,

Dan Schless

exiftool -XMP-MP:all people.jpg Region Rectangle : 0.268786, 0.167144, 0.277457, 0.183381, 0.598266, 0.424069, 0.209 +538, 0.138491 Region Person Display Name : Fred Flintstone, Patriarch, Betty Boop exiftool -XMP-MP:all -X people.jpg <?xml version='1.0' encoding='UTF-8'?> <rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'> <rdf:Description rdf:about='people.jpg' xmlns:et='http://ns.exiftool.ca/1.0/' et:toolkit='Image::ExifTool 8.07' xmlns:XMP-MP='http://ns.exiftool.ca/XMP/XMP-MP/1.0/'> <XMP-MP:RegionRectangle> <rdf:Bag> <rdf:li>0.268786, 0.167144, 0.277457, 0.183381</rdf:li> <rdf:li>0.598266, 0.424069, 0.209538, 0.138491</rdf:li> </rdf:Bag> </XMP-MP:RegionRectangle> <XMP-MP:RegionPersonDisplayName> <rdf:Bag> <rdf:li>Fred Flintstone, Patriarch</rdf:li> <rdf:li>Betty Boop</rdf:li> </rdf:Bag> </XMP-MP:RegionPersonDisplayName> </rdf:Description> </rdf:RDF>
Direct Responses: 12332 | Write a response
Posted on 2010-02-07 03:48:06.525285-08 by exiftool in response to 12330
Re: XMP to IPTC Keywords
Hi Dan,

Do you want to replace the original keywords in the destination file:

exiftool "-keywords<regionpersondisplayname" people.jpg

or add to them?:

exiftool "-keywords+<regionpersondisplayname" people.jpg

Or if you wanted to copy the tags to another file, you would use the -tagsFromFile option:

exiftool -tagsfromfile people.jpg "-keywords<regionpersondisplayname" DSTFILE

You don't have to specify "-IPTC:Keywords" in any of these commands because exiftool writes to IPTC preferentially, however it never hurts to be more specific if you want.

- Phil
Direct Responses: 12334 | Write a response
Posted on 2010-02-07 09:22:00.98361-08 by dschless in response to 12332
Re: XMP to IPTC Keywords
Thanks Phil ... of course that answer just brought up another question: when using exiftool "-keywords<regionpersondisplayname" people.jpg how can I prefix each of the keywords with text of my choosing? I tried exiftool "-kewords<person $regionpersondisplayname" people.jpg but that resulted in the two keywords being combined into one: person Fred Flintstone, Patriarch, Betty Boop when what I was looking for is the two original keywords each prefixed with the text 'person': person Fred Flintsonte, Patriarch person Betty Boop Thanks, Dan Schless
Direct Responses: 12335 | Write a response
Posted on 2010-02-07 11:32:02.34081-08 by exiftool in response to 12334
Re: XMP to IPTC Keywords
Hi Dan,

Adding a prefix to each keyword is tricky because of the complications of the list-type tag, but this can be done with a user-defined tag. If you really want I could work up an example config file to do this, but this will have to wait because I don't have the time at the moment.

- Phil
Direct Responses: 12336 | Write a response
Posted on 2010-02-07 14:17:31.747328-08 by dschless in response to 12335
Re: XMP to IPTC Keywords
An example, when you have the time, will be appreciated. Dan Schless
Direct Responses: 12337 | Write a response
Posted on 2010-02-07 15:54:18.065055-08 by exiftool in response to 12336
Re: XMP to IPTC Keywords
Here you go. Use an argument like "-keywords<myperson" with this config file:

%Image::ExifTool::UserDefined = ( 'Image::ExifTool::Composite' => { MyPerson => { Require => 'RegionPersonDisplayName', ValueConv => q{ my @v = ref $val ? @$val : $val; $_ = "Prefix $_" foreach @v; return \@v; }, }, }, ); 1; # end

Replace "Prefix" with your own text.

- Phil
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.