Hi All
First of all I know that this is NOT a problem caused by Exiftool.
I've come across an issue when reading XMP-Plus tags that have been written by Photoshop where there are lines where one value is not present.
The following six lines are an example of the two columns in the Copyright Owners table where nv represents no value.
Line 1- nv Default
Line 2- CON NAME2 ID23
Line 3- cn3 nv
Line 4- cn4 nv
Line 5- nv id5
Line 6- nv id6
Tags written by Photo Mechanic do not present a problem....
The following XML is taken from an image saved by PM.
In each "Resource" there is both the CopyrightOwnerName and CopyrightOwnerID tags even if there is no value. When Exiftool reads this it produces the same amount of values, and reads the "no value" entries.
<plus:CopyrightOwner>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName/>
<plus:CopyrightOwnerID>Defaults</plus:CopyrightOwnerID>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName>CON NAME2</plus:CopyrightOwnerName>
<plus:CopyrightOwnerID>ID 2</plus:CopyrightOwnerID>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName>cn3</plus:CopyrightOwnerName>
<plus:CopyrightOwnerID/>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName>cn4</plus:CopyrightOwnerName>
<plus:CopyrightOwnerID/>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName/>
<plus:CopyrightOwnerID>id5</plus:CopyrightOwnerID>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName/>
<plus:CopyrightOwnerID>id6</plus:CopyrightOwnerID>
</rdf:li>
</rdf:Seq>
</plus:CopyrightOwner>
As saved by Photo Mechanic
The following XML is taken from the same image saved by Photoshop.
In each "Resource" it only enters the CopyrightOwnerName or the CopyrightOwnerID tag where there is a value. When Exiftool reads this it produces three CopyrightOwnerName tags and four CopyrightOwnerID tags. When these are entered into my datagridview the entries are out of synchronisation and will only add four rows instead of six.
<plus:CopyrightOwner>
<rdf:Seq>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerID>Defaults</plus:CopyrightOwnerID>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName>CON NAME2</plus:CopyrightOwnerName>
<plus:CopyrightOwnerID>ID 23</plus:CopyrightOwnerID>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName>cn3</plus:CopyrightOwnerName>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerName>cn4</plus:CopyrightOwnerName>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerID>id5</plus:CopyrightOwnerID>
</rdf:li>
<rdf:li rdf:parseType="Resource">
<plus:CopyrightOwnerID>id6</plus:CopyrightOwnerID>
</rdf:li>
</rdf:Seq>
</plus:CopyrightOwner>
As saved by Photoshop
When Photoshop and PhotoMechanic read either XML, they present the values correctly.
Is there any way that I can read each "Resource" and include a value for the missing tag?
Is this a case for me to learn how to read an XML document with VB.NET?
The issue is the same for the "Image Creators" and "Image Registry Entries" tables.
Thanks in advance.
John
Hi John,
The only way to read these with ExifTool and maintain the correlations is to read them as structures. But then you are stuck dealing with a structured output (as you suspected). But you aren't limited to XML only. For structured ExifTool output, the JSON output (-struct -j) is probably the best, and easiest to read:
"CopyrightOwner": [{
"CopyrightOwnerID": "Defaults"
},{
"CopyrightOwnerID": "ID 23",
"CopyrightOwnerName": "CON NAME2"
},{
"CopyrightOwnerName": "cn3"
},{
"CopyrightOwnerName": "cn4"
},{
"CopyrightOwnerID": "id5"
},{
"CopyrightOwnerID": "id6"
}],
Or the ExifTool serialized structure (https://exiftool.org/struct.html#Serialize) output (-struct) is another possibility:
[{CopyrightOwnerID=Defaults},{CopyrightOwnerID=ID 23,CopyrightOwnerName=CON NAME2},{CopyrightOwnerName=cn3},{CopyrightOwnerName=cn4},{CopyrightOwnerID=id5},{CopyrightOwnerID=id6}]
Unfortunately there is no way with ExifTool to "fill in the blanks" as you had hoped.
- Phil
Edit: Ah. In another thread I see you are already using the JSON output format, so the solution may be as easy as just adding -struct to your command.
Hi Phil
I didn't realise that you could get the CopyrightOwner tags as a structure.
I used the -struct method to obtain the Licensor and ArtworkOrObect structures and wrote some code to extract the values, I will do the same for the others three.
Many Thanks
John
Hi Phil,
I have been working on a solution for John for this issue and I have run into a problem with writing a structured value. I tried to use your example here https://exiftool.org/struct.html (https://exiftool.org/struct.html) for a RegionList. As usual I'm using -stayopen and writing commands to stdin.
The structure I'm using is the exact same format as what is output with -struct for this file. I even took the output (as shown below) and cut and pasted it into my code to check it. From exiftool for the RegionList using -struct on my test file and I get:
Region Info : {AppliedToDimensions={H=3000,Unit=pixel,W=4000},RegionList=[{Area={H=0.576,Unit=normalized,W=0.518,X=0.271,Y=0.312},Name=Man,Type=Face},{Name=Baby},{Area={H=0.403333,Unit=normalized,W=0.3625,X=0.67175,Y=0.611667},Type=Face}]}
Then I simply try to write that exact same thing back with
-q
-RegionInfo="{AppliedToDimensions={H=3000,Unit=pixel,W=4000},RegionList=[{Area={H=0.576,Unit=normalized,W=0.518,X=0.271,Y=0.312},Name=Man,Type=Face},{Name=Baby},{Area={H=0.403333,Unit=normalized,W=0.3625,X=0.67175,Y=0.611667},Type=Face}]}"
-overwrite_original
D:\ExifToolVBNetDemo - for John Struct related\IMG_2324bad.JPG
-execute
-execute
but then exiftool returns the error:
Warning: Improperly formed structure for XMP-mwg-rs:RegionInfo
I also tried adding an extra { at the beginning and } and the end like:
-RegionInfo="{{AppliedToDimensions={H=3000,Unit=pixel,W=4000},RegionList=[{Area={H=0.576,Unit=normalized,W=0.518,X=0.271,Y=0.312},Name=Man,Type=Face},{Name=Baby},{Area={H=0.403333,Unit=normalized,W=0.3625,X=0.67175,Y=0.611667},Type=Face}]}}"
but got the same warning message.
also tried something simple:
-RegionInfo="{AppliedToDimensions={H=3020,Unit=pixel,W=4030}}"
same warning message again.... :(
Not sure where the error is in my structure? I must be doing something wrong??
Thanks!
Curtis
I could be wrong but I don't think you want the quotes.
From the docs on -@ (http://www.exiftool.org/exiftool_pod.html#argfile)
"Normal shell processing of arguments is not performed, which among other things means that arguments should not be quoted..."
Thank you StarGeek! That fixed my problem!