Skip to content

TagLib breaks XMP metadataworkinggroup face tags #358

Open
@Agendum

Description

@Agendum

When parsing XMP, it appears to set the tag parent type as a struct when it encounters a Description:

} else if (node.Is (RDF_NS, DESCRIPTION_URI)) {
    parent.Type = XmpNodeType.Struct;
} else {

Yet when it is written back out, the Description object is lost:

} else if (Type == XmpNodeType.Simple || Type == XmpNodeType.Struct) {
    var node = XmpTag.CreateNode (parent.OwnerDocument, Name, Namespace);
    node.InnerText = Value;

    if (Type == XmpNodeType.Struct) {
        // Structured types are always handled as a parseType=Resource node. This way, IsReallySimpleType will
        // not match for child nodes, which makes sure they are added as extra nodes to this node. Does the
        // trick well, unit tests that prove this are in XmpSpecTest.
        XmlAttribute attr = XmpTag.CreateAttribute (parent.OwnerDocument, XmpTag.PARSE_TYPE_URI, XmpTag.RDF_NS);
        attr.Value = "Resource";
        node.Attributes.Append (attr);
    }

    AddAllQualifiersTo (node);
    AddAllChildrenTo (node);
    parent.AppendChild (node);
}

This is causing an unmodified document to be written out differently, breaking apps which read face data.

Before (working):

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 5.1.2">
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:mwg-rs="http://www.metadataworkinggroup.com/schemas/regions/" xmlns:stDim="http://ns.adobe.com/xap/1.0/sType/Dimensions#" xmlns:stArea="http://ns.adobe.com/xmp/sType/Area#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmp:ModifyDate="2016-06-03T23:37:34-07:00">
      <mwg-rs:Regions rdf:parseType="Resource">
        <mwg-rs:AppliedToDimensions stDim:w="2368" stDim:h="3464" stDim:unit="pixel"/>
        <mwg-rs:RegionList>
          <rdf:Bag>
            <rdf:li>
              <rdf:Description mwg-rs:Name="Person Name" mwg-rs:Type="Face">
                <mwg-rs:Area stArea:x="0.320735" stArea:y="0.369948" stArea:w="0.160895" stArea:h="0.132506" stArea:unit="normalized"/>
              </rdf:Description>
            </rdf:li>
          </rdf:Bag>
        </mwg-rs:RegionList>
      </mwg-rs:Regions>
    </rdf:Description>
  </rdf:RDF>
</x:xmpmeta>

After (TagLib-generated, broken):

<x:xmpmeta xmlns:x="adobe:ns:meta/">
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <rdf:Description xmp:ModifyDate="2024-10-03T18:47:40.4483443-07:00" xmlns:xmp="http://ns.adobe.com/xap/1.0/">
      <ns1:Regions rdf:parseType="Resource" xmlns:ns1="http://www.metadataworkinggroup.com/schemas/regions/">
        <ns1:AppliedToDimensions stDim:w="2368" stDim:h="3464" stDim:unit="pixel" xmlns:stDim="http://ns.adobe.com/xap/1.0/sType/Dimensions#"/>
        <ns1:RegionList>
          <rdf:Bag>
            <rdf:li rdf:parseType="Resource">
              <ns1:Name>Person Name</ns1:Name>
              <ns1:Type>Face</ns1:Type>
              <ns1:Area ns2:x="0.320735" ns2:y="0.369948" ns2:w="0.160895" ns2:h="0.132506" ns2:unit="normalized" xmlns:ns2="http://ns.adobe.com/xmp/sType/Area#"/>
            </rdf:li>
          </rdf:Bag>
        </ns1:RegionList>
      </ns1:Regions>
      <dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">
        <rdf:Seq>
          <rdf:li/>
        </rdf:Seq>
      </dc:creator>
    </rdf:Description>
  </rdf:RDF>
</x:xmpmeta>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions