GNOME Bugzilla – Bug 782208
Unable to register 'Iptc4xmpExt' XMP namespace
Last modified: 2018-05-22 12:36:03 UTC
I think my problem is caused by Exiv2 abbreviating Iptc4xmpExt to iptcExt. I'm trying to add location metadata such as Xmp.iptcExt.LocationShown[1]/Iptc4xmpExt:City. I get "Unknown namespace prefix for qualified name" errors unless the XMP file already has the Iptc4xmpExt namespace registered. If I try to register it with register_xmp_namespace('http://iptc.org/std/Iptc4xmpExt/2008-02-29/', 'Iptc4xmpExt') the call return false. I assume this is because Exiv2 already has the iptcExt namespace predefined and thinks they're equivalent.
As far as I understood you can just use iptcExt in you code, the image will be written correctly nevertheless.
The problem is with the second part of the tag name. Using Xmp.iptcExt.LocationShown[1]/iptcExt:City allows me to save data without registering the 'Iptc4xmpExt' namespace, but the file can't then be modified by other tools. As far as I can tell the second part (Iptc4xmpExt:City) has to use the Iptc4xmpExt namespace and that namespace has to be registered.
I've found a workaround now: 1/ set the 'bag' tag Xmp.iptcExt.LocationShown 2/ use generate_xmp_packet to get a string of XMP data 3/ change every occurrence of 'iptcExt' in the string to 'Iptc4xmpExt' 4/ create a new GExiv2.Metadata object and use open_buf to read the modified string This gets the 'Iptc4xmpExt' namespace registered by the back door and allows the Xmp.iptcExt.LocationShown[1]/Iptc4xmpExt:City tag to be used without errors.
ew, that sounds ugly. Reopen, that needs something more user-friendly.
There is an inconsistency in how Exiv2 writes XMP data. 1/ Create an empty XMP file: echo "<x:xmpmeta x:xmptk='XMP Core 4.4.0-Exiv2' xmlns:x='adobe:ns:meta/'></x:xmpmeta>" >test.xmp 2/ Write some tags: exiv2 -M"set Xmp.iptc.Location XmpText West Wallaby St" test.xmp exiv2 -M"set Xmp.iptcExt.DigitalSourcefileType XmpText camerajpeg" test.xmp 3/ Look at the file: more test.xmp <?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2"> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:iptcExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/" xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/" iptcExt:DigitalSourcefileType="camerajpeg" Iptc4xmpCore:Location="West Wallaby St"/> </rdf:RDF> </x:xmpmeta> <?xpacket end="w"?> Note that the Xmp.iptc tag uses the proper Iptc4xmpCore namespace but the Xmp.iptcExt tag does not use the proper Iptc4xmpExt namespace. I'm not enough of an XMP expert to say if this is a bug or not.
I will take that to the exiv2 project. It really looks odd.
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gexiv2/issues/24.