dc:subject contains duplicates when using -USE MWG and -tagsfromfile

Started by Mac2, September 23, 2011, 02:29:29 AM

Previous topic - Next topic

Mac2

I have a file containing one keyword in the dc:subject tag:

1. Clear
exiftool -all= image.jpg

2. Add Keyword
exiftool -xmp:subject="Foo" image.jpg

3. Test
exiftool -all image.jpg
[XMP]           XMP Toolkit                   : Image::ExifTool 8.64
[XMP]           Subject                       : Foo


4. Produce a XMP file from the source image

exiftool -use mwg -tagsfromfile image.jpg image.xmp

<rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:subject>
   <rdf:Bag>
      <rdf:li>Foo</rdf:li>
      <rdf:li>Foo</rdf:li>
   </rdf:Bag>
  </dc:subject>
</rdf:Description>


Is this the intended behavior or a glitch? Without -use mwg the subject "Foo" appears only once.

I'm currently struggling my way through the MWG spec and I want to use the MWG support thankfully available in ExifTool to produce the XMP tags on extract and synchronize back when updating certain fields. So this is all new to me and I may be wrong.

BogdanH

Hi,

Can't say if that's intended behaviour -it isn't expected behaviour, though.
Phil?

Bogdan

Phil Harvey

Definitely a glitch.  I'll look into this and post back when I know what is happening.

Thanks for reporting this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

Good catch.  The problem was an oversight in the logic to write associated list-type tags.  Here is what was happening:

1) When extracting, -use MWG was extracting XMP:Subject (foo) and also generating a MWG:Keyword (foo).

2) When copying these values, XMP:Subject was copied properly, but when MWG:Keywords was written it also wrote the associated XMP:Subject tag.  However, the logic failed to properly reset the existing entries in the list before writing the new value, so its value got added to the list, causing the entry to be duplicated.

I have fixed this and ExifTool 8.65 should solve this problem.

Thanks again for the report.

Note that this behaviour is expected if -addTagsFromFile is used instead of -tagsFromFile, so this will still occur in version 8.65 if -addTagsFromFile is used.

One final point: There is still a side-effect when copying to XMP like this with -use MWG...  The output XMP will contain a XMP-pdf:Keywords that won't exist without -use MWG because MWG:Keywords is generated with -use MWG and this tag is copied to XMP-pdf:Keywords if no group is specified.  A bit weird, but I don't see any harm in this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Mac2

Hi, Phil and Bogdan

thanks for the clarification. I noticed the PDF keyword too, but settled to ignore it.

What I'm trying to achieve is to import metadata into a database. I use -X output for that.
But I also want to create an XMP record if the file has none yet.

So I first create an XMP file with -tagsfromfile from the original image.
From this XMP file and the original image I produce then a combined output XML with the -X option (and various flags).
This gives me the richest metadata to work with. This is where the MWG came in and why I spotted this.

While still making my way through all the MUST, SHOULD, COULD, WOULD and MAYBEBETTERIFNOT's in the MWG  ::) specification I'm trying to put this all into ExifTool terms.

I need to find out how much ExifTool already does in the area of reconciliation between the different standards and how much I need to do myself, in my code.  All these little rules of what goes where, what has to be filled from what and when and how. And of course I'm still learning about ExifTool and what it can do, and how I make it do it.

The MWG tags, combined with your args file already go a long way. I'm thankful for that because the less I need to hard-code in my application the better. I want to keep ExifTool in control as much as possible.

(PS.: Thanks for adding the "tagged -execute option in the last update  :D  Much easier and safer to track multiple pending -stay_open executes now!)

Phil Harvey

Just a suggestion:  If you are just interested in the MWG tags, then you can limit the copy to only these:

exiftool -tagsfromfile image.jpg -mwg:all image.xmp

(Note that using -mwg:all on the command line automatically invokes -use mwg)

This avoids the quirk of writing XMP-pdf:Keywords.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).