Feature #1040

MWG-KW schema

Added by Alan Pater over 6 years ago. Updated over 6 years ago.

Target version:
Start date:
12 Mar 2015
Due date:
% Done:


Estimated time:


This patch adds support for Metadata Working Group (Hierarchical) Keywords. I previously added support for Lightroom Hierarchical Tags, a custom XMP schema in wide use by Adobe. MWG-KW is the schema developed and published in MWG guidlines.

Exiftool has included support for this schema for some time. With this patch, exiv2 can create and modify these hierarchical keywords as well.

I have tested against exiftool and not seen any errors.


mwg-kw.patch (4.01 KB) mwg-kw.patch Alan Pater, 12 Mar 2015 20:40
mwg-kw.test.jpg (26.3 KB) mwg-kw.test.jpg mwg-kw Test image Alan Pater, 12 Mar 2015 20:49

Related issues

Related to Exiv2 - Bug #784: Writing writes wrong datatypeClosed02 Aug 2011


Associated revisions

Revision 3634 (diff)
Added by Robin Mills over 6 years ago

#1040. Thank You Alan for reporting this and providing the patch. Thank You Thomas for validating this change.

Revision 3642 (diff)
Added by Robin Mills over 6 years ago

#1040. Added test regression detector.

Revision 3643 (diff)
Added by Robin Mills over 6 years ago

#784 and #1040. Test regression detector.

Revision 3657 (diff)
Added by Alan Pater over 6 years ago

#1040 doc template for mwg-kw schema



Updated by Robin Mills over 6 years ago

  • Status changed from New to Assigned
  • Target version set to 0.25

Thanks very much for providing this, Alan. I'll have a look at this and submit it over the weekend.


Updated by Thomas Beutlich over 6 years ago

Patch is working. This is the output of the XMP dump of the provided test file:

Xmp.mwg-kw.Keywords                                 XmpText      0 type="Struct" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy                XmpText      0 type="Bag" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[1]             XmpText      0 type="Struct" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[1]/mwg-kw:Keyword XmpText      3 cat
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[1]/mwg-kw:Children XmpText      0 type="Bag" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[1]/mwg-kw:Children[1] XmpText      0 type="Struct" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[1]/mwg-kw:Children[1]/mwg-kw:Keyword XmpText      7 Siamese
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[2]             XmpText      0 type="Struct" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[2]/mwg-kw:Keyword XmpText      7 Felidae
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[2]/mwg-kw:Children XmpText      0 type="Bag" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[2]/mwg-kw:Children[1] XmpText      0 type="Struct" 
Xmp.mwg-kw.Keywords/mwg-kw:Hierarchy[2]/mwg-kw:Children[1]/mwg-kw:Keyword XmpText      6 Jaguar

It messes up the layout but I guess this is general problem with long identifiers of hierarchical data.


Updated by Robin Mills over 6 years ago

Patch submitted. r3633. Thanks to Alan for reporting and providing the patch. Thanks to Thomas for validating the fix.

Thanks for looking at this Thomas, it has been on my TODO list for more than a week. (#1042/#1043 have been time-consuming). I think we should about add the test file to the test harness.

Alan: is there any reason (example copyright) to prevent us from copying your test file (mwg-kw.test.jpg) into our test suite? It will probably be renamed exiv2-bug1040.jpg to fit the name pattern of the test files.


Updated by Alan Pater over 6 years ago

Very cool! Thank you Thomas and Robin!

Yes, go ahead and include the test image into the test suite. It can be considered to be in the public domain. Next time I'll be sure to include a Creative Commons statement to that effect.


Updated by Robin Mills over 6 years ago

  • Assignee changed from Alan Pater to Robin Mills

Thanks Alan. I'm not a legal guy and easily confused by all the different license types. And I'm not sure how to record the license. Perhaps it should be put as a Exif.Photo.UserComment in the jpg.

I've changed the Assignee to myself to add Alan's file to the test suite and to update the test suite code appropriately. When tomorrow's build with the test changes is successful on our build/test server, I'll mark this as "Resolved".


Updated by Robin Mills over 6 years ago

Submitted: r3642 and r3543

I've added a test to make ensure the output of the command $ exiv2 -px mwg-kw.test.jpg is always the same as Thomas reports in Item3 above.

I'm a little confused by the discussion about the spelling of hierarchy. I've also added a parallel test on the file you provided for #784

$ exiv2 -px # renamed to exiv2-bug784.jpg
Xmp.dc.format                                XmpText    10  image/jpeg
Xmp.dc.rights                                LangAlt     1  lang="x-default" Public Domain. Do whatever you like with this image
Xmp.dc.subject                               XmpBag      6  1st, 2nd, next1, next2, root, root0
Xmp.xmpMM.DocumentID                         XmpText    32  004D48F936062EF5085A81BF96D4C494
Xmp.xmpMM.OriginalDocumentID                 XmpText    32  004D48F936062EF5085A81BF96D4C494
Xmp.xmpMM.InstanceID                         XmpText    44  xmp.iid:f74f0d02-e921-134e-8107-1dda17aad853
Xmp.xmpMM.History                            XmpText     0  type="Seq" 
Xmp.xmpMM.History[1]                         XmpText     0  type="Struct" 
Xmp.xmpMM.History[1]/stEvt:action            XmpText     5  saved
Xmp.xmpMM.History[1]/stEvt:instanceID        XmpText    44  xmp.iid:f74f0d02-e921-134e-8107-1dda17aad853
Xmp.xmpMM.History[1]/stEvt:when              XmpText    25  2015-03-24T20:35:55-05:00
Xmp.xmpMM.History[1]/stEvt:softwareAgent     XmpText    39  Adobe Photoshop Lightroom 4.4 (Windows)
Xmp.xmpMM.History[1]/stEvt:changed           XmpText     9  /metadata
Xmp.xmp.MetadataDate                         XmpText    25  2015-03-24T20:35:55-05:00                          XmpText    12                   XmpBag      2  root0|next1|next2, root|1st|2nd
894 rmills@rmillsmbp:~/gnu/exiv2/trunk/test $ 
I hope these are the correct tests and we can mark both issues #1040 and #784 as resolved.


Updated by Robin Mills over 6 years ago

  • Assignee changed from Robin Mills to Alan Pater


I hope I've got this right. If you're happy, please change the status to "Resolved" and we're done. If further action is required, please assign it to me (or Thomas) and explain what needs attention.


Updated by Alan Pater over 6 years ago

  • Status changed from Assigned to Resolved

Looks good to me! I confirmed interoperability with exiftool.


Updated by Alan Pater over 6 years ago

  • % Done changed from 50 to 100

Updated by Andreas Huggel over 6 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF