Hi
my usecase is to use exif tool to insert a new xmp region tag (including Area,Type,Name,Description) into a jpeg file. But i do not know if there is already a xmp region tag present and if there is if it contains all necesarry subtags (Area,Type,Descrition...). Some other application might have already inserted some data and I only want to add my new data without changing the existing.
Example
-Add Joe to picture (some other application did that) without description
exiftool -RegionName+=Joe pic.jpg
exiftool -RegionAreaH+=0.2 pic.jpg
exiftool -RegionAreaW+=0.2 pic.jpg
exiftool -RegionAreaX+=0.5 pic.jpg
exiftool -RegionAreaY+=0.5 pic.jpg
exiftool -RegionAreaUnit+=normalize pic.jpg
exiftool -RegionType+=Face pic.jpg
-Add Sue to picture with description (i want to do that)
exiftool -RegionName+=Sue pic.jpg
exiftool -RegionAreaH+=0.1 pic.jpg
exiftool -RegionAreaW+=0.1 pic.jpg
exiftool -RegionAreaX+=0.2 pic.jpg
exiftool -RegionAreaY+=0.2 pic.jpg
exiftool -RegionAreaUnit+=normalize pic.jpg
exiftool -RegionType+=Face pic.jpg
exiftool -RegionDescription+=SuesFunnyFaceDescription
This results in the following xmp XML where you can see that Sues description ends up with Joe.
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 10.17'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about=''
xmlns:mwg-rs='http://www.metadataworkinggroup.com/schemas/regions/'
xmlns:stArea='http://ns.adobe.com/xmp/sType/Area#'>
<mwg-rs:Regions rdf:parseType='Resource'>
<mwg-rs:RegionList>
<rdf:Bag>
<rdf:li rdf:parseType='Resource'>
<mwg-rs:Area rdf:parseType='Resource'>
<stArea:h>0.2</stArea:h>
<stArea:unit>normalize</stArea:unit>
<stArea:w>0.2</stArea:w>
<stArea:x>0.5</stArea:x>
<stArea:y>0.5</stArea:y>
</mwg-rs:Area>
<mwg-rs:Description>SuesFunnyFaceDescription</mwg-rs:Description>
<mwg-rs:Name>Joe</mwg-rs:Name>
<mwg-rs:Type>Face</mwg-rs:Type>
</rdf:li>
<rdf:li rdf:parseType='Resource'>
<mwg-rs:Area rdf:parseType='Resource'>
<stArea:h>0.1</stArea:h>
<stArea:unit>normalize</stArea:unit>
<stArea:w>0.1</stArea:w>
<stArea:x>0.2</stArea:x>
<stArea:y>0.2</stArea:y>
</mwg-rs:Area>
<mwg-rs:Name>Sue</mwg-rs:Name>
<mwg-rs:Type>Face</mwg-rs:Type>
</rdf:li>
</rdf:Bag>
</mwg-rs:RegionList>
</mwg-rs:Regions>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
Is there any way to make sure that all information is created in the same rdf:li section? Or if i knew that Joe is missing the description tag - can I specify that the Description should be added to the 2nd Element?
You seem to have two problems:
QuoteIs there any way to make sure that all information is created in the same rdf:li section
To be sure all elements of the RegionInfo structure are written together, write them as a structure:
exiftool -regionlist+="{Area={H=0.2,Unit=normalize,W=0.2,X=0.5,Y=0.5},Name=Joe,Type=Face}" pic.jpgSee Writing Structured Information (https://exiftool.org/struct.html#Writing) for more information.
QuoteI only want to add my new data without changing the existing
This is tricky, and can't be easily done via the command line. It could be done efficiently via a Perl script using the ExifTool API.
From the command line, a technique could be to fill all of the missing structure elements with dummy fields, then replace the one you want and delete the other dummy fields afterwards.
- Phil
Hi Phil,
thank you for your reply. Inserting the data as structure was exactly the thing i was looking for.