Bug 382645 - XMP sidecar file should not contain a packet wrapper
Summary: XMP sidecar file should not contain a packet wrapper
Status: RESOLVED NOT A BUG
Alias: None
Product: digikam
Classification: Applications
Component: Metadata-Sidecar (show other bugs)
Version: 7.2.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-24 06:24 UTC by Michael
Modified: 2023-04-23 10:13 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 8.1.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael 2017-07-24 06:24:25 UTC
The XMP sidecar file that digikam produces should not contain the XMP packet wrapper. In regard to the specification it should produce a "well formed XML file" including a XML header. You can see a similar bug report and discussion for darktable here: https://redmine.darktable.org/issues/8534

Michael Zabel
Comment 1 caulier.gilles 2017-07-28 04:47:30 UTC
Both Application use Exiv2 in backgroud to generate sidecar. Report this problem as UPSTREAM bug to Exiv2 team.

Gilles Caulier
Comment 2 Michael 2017-07-28 05:21:10 UTC
(In reply to caulier.gilles from comment #1)
> Both Application use Exiv2 in backgroud to generate sidecar. Report this
> problem as UPSTREAM bug to Exiv2 team.
> 
> Gilles Caulier
This is not an Exiv2 bug. As I wrote some years ago in the mentioned darktable bug report (please see the provided link above) you can decide how to generate the xmp file using the flag Exiv2::XmpParser::omitPacketWrapper. Just use this flag if you want to write to a sidecar file and write a XML header first (please see the provided code example in the link).
BTW, darktable fixed this 2 years ago. And if I remember right, digikam did it right in some former versions.

Regards,
Michael
Comment 3 caulier.gilles 2021-04-08 17:37:49 UTC
Maik, 

What do you think about this old entry ? Why we need to generate xmp sidecar without XML packet description ?  What the gain ? What's about the interoperability with other application ?

Removing XML definition can reduce compatibility after all. For me this file must be resolved as WONT FIX...

Gilles
Comment 4 Michael 2021-04-12 14:49:14 UTC
(In reply to caulier.gilles from comment #3)
> Maik, 
> 
> What do you think about this old entry ? Why we need to generate xmp sidecar
> without XML packet description ?  What the gain ? What's about the
> interoperability with other application ?
> 
> Removing XML definition can reduce compatibility after all. For me this file
> must be resolved as WONT FIX...
> 
> Gilles

Gilles,

please don't mix up XMP packet wrappers and XML headers. These are two different things. Unfortunately, the Exiv2 documentation for the flag omitPacketWrapper is wrong in this regard ('Omit the XML packet wrapper.'). This flag omits the XMP packet wrapper (there is no XML packet wrapper). 

A XMP packet wrapper is intended for embedding XMP data into binary files and starts with: 
<?xpacket begin=

For XMP sidecar files you should omit this wrapper and write a XML header instead - before writing the XMP data:
<?xml version="1.0" encoding="UTF-8"?> 

This XML header is missing in the current digiKam release.

Michael
Comment 5 Maik Qualmann 2021-04-12 19:05:58 UTC
If I see that correctly, Exiv2 does not write the "<?xml version="1.0" encoding="UTF-8"?>" Header, but Darktable.
The option Exiv2::XmpParser::omitPacketWrapper only prevents an XMP packet wrapper from being created, but only in the Exiv2::XmpParser::encode() function. And that's exactly the difference between digiKam and Darktable, we create an Exiv2::Image of the Exiv2::ImageType::xmp type ==> sidecar.
We cannot set the Exiv2::XmpParser::omitPacketWrapper at all. Darktable uses Exiv2::XmpParser::encode() to copy the XMP metadata into a string and then write it to a file. I think our Xmp creation is the right way provided by Exiv2.

Maik

Maik
Comment 6 Maik Qualmann 2021-04-12 19:43:06 UTC
If I create a sidecar with "exiv2 -eX image.jpg", the format is identical to digiKam. In addition, we have to use an Exiv2::Image so that Exif and IPTC metadata can also be mapped to XMP via the internal Exiv2 conversion table. For me, the Darktable sidecar is an XML file to map the history of the image processing.

Maik
Comment 7 Michael 2021-04-13 05:09:40 UTC
Maik,

that's not correct in my opinion. A XMP sidecar file should start with a XML header. If Exiv2 doesn't write this header that's IMHO a bug.

Please have a look at the XMP specification from Adobe, Part 3, Storage in files:
https://www.adobe.com/devnet/xmp.html

On page 7 in section "External storage of metadata" you will find this topic:
"Write the external file as a complete, well-formed XML document, including the leading XML declaration."

Michael
Comment 8 Maik Qualmann 2021-04-13 06:10:06 UTC
You forget that we are writing an Exiv2::Image of type XMP. Yes, it's XML formatted, but the packet wrapper is one of it. The best test is to test it with ExifTool. ExifTool also writes a packet wrapper and not an XML header!

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.13'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

Maik
Comment 9 Michael 2021-04-13 06:24:06 UTC
I know that ExifTool writes a packet wrapper for sidecar files. But for my understanding of the XMP specification this is not correct. I think the specification should be more relevant than the output of a certain application or library. But Darktable does it right in my opinion.

Michael
Comment 10 Maik Qualmann 2021-04-13 08:41:18 UTC
Here is an example of a sidecar file in the Wikipedia:

https://en.wikipedia.org/wiki/Extensible_Metadata_Platform

Maik
Comment 11 Michael 2021-04-13 09:12:55 UTC
I don't see an example of a sidecar file. I only see an example for embedded XMP data in a JPEG file ("This is an example XML document for serialized XMP metadata in a JPEG photo"). 
As I wrote before a packet wrapper must be used for serializing or embedding XMP data in binary files, but not for external sidecar files.
Why you don't refer to the original specification from Adobe?

Michael
Comment 12 Maik Qualmann 2021-04-14 07:50:21 UTC
I already wrote that we are using the API to save an Exiv2 "image" in XMP format. We cannot change this behavior, the way Darktable does it is not applicable to digiKam. The problem would have to be discussed again on the part of Exiv2 and ExifTool. I also found ExifTool's thread on this topic, Phil doesn't want to change it either at the moment. When searching for XMP files from Photoshop, I only found older files that also contain the paket wrapper. How Photoshop is currently handling it would have to be tested. From my side, this bug report is in the wrong place at digiKam.

Maik
Comment 13 caulier.gilles 2023-04-23 10:13:26 UTC
Hi Maik,

For me this entry a nothing to do in the digiKam bugzilla. All this technical questions must be posted in Exiv2 and/or ExifTool bugzilla. As all work as expected in the viewpoint of interroperability with other photo management application. I close this file now.

Gilles