Project

General

Profile

Xmp.xmpMM.DerivedFrom

Added by Mikayel Egibyan over 6 years ago

Hi,

Can anyone advice what is the correct way to write DerivedFrom tag?
I have tried doing it both as general tag and as structure, but it didn't work out.

Thank you!


Replies (6)

RE: Xmp.xmpMM.DerivedFrom - Added by Robin Mills over 6 years ago

Mikayel

I hope you're well - we haven't spoken for some time.

May I ask you to explain your question in more depth. I'm not sure what you are asking as I've never wanted to use the DerivedFrom tag. Here's what I have tried. I downloaded an image of Stonehenge from the forum and listed the Xmp tags

651 rmills@rmillsmbp:~/temp $ curl http://dev.exiv2.org/attachments/download/805/DSC_7154.jpg > Stonehenge.jpg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 6597k    0 6597k    0     0  3212k      0 --:--:--  0:00:02 --:--:-- 3213k
652 rmills@rmillsmbp:~/temp $ 657 rmills@rmillsmbp:~/temp $ exiv2 -pa -g Xmp Stonehenge.jpg 
Xmp.xmp.Rating                               XmpText     1  0
Xmp.xmp.ModifyDate                           XmpText    25  2015-07-16T20:25:28+01:00
Xmp.dc.description                           LangAlt     1  lang="x-default" Classic View
$
Then I've defined the DerivedFrom tag and listed the tags again. Seems to work out perfectly.
$ exiv2 -M"set Xmp.xmpMM.DerivedFrom http://dev.exiv2.org/attachments/download/805/DSC_7154.jpg" Stonehenge.jpg 
$ exiv2 -pa -g Xmp Stonehenge.jpg 
Xmp.xmp.Rating                               XmpText     1  0
Xmp.xmp.ModifyDate                           XmpText    25  2015-07-16T20:25:28+01:00
Xmp.xmpMM.DerivedFrom                        XmpText    58  http://dev.exiv2.org/attachments/download/805/DSC_7154.jpg
Xmp.dc.description                           LangAlt     1  lang="x-default" Classic View
$ 
Can you explain what you've tried and why "it didn't work out".

I've also looked at the Adobe Spec concerning the derivedFrom tag. I don't think they give an example in the spec. So, although I've used the tag to record the URL from which I obtained the image, I'm not advocating that this is appropriate use.

RE: Xmp.xmpMM.DerivedFrom - Added by Robin Mills over 6 years ago

Mikayel

I've had another look at this matter and googled up an example of somebody using DerivedFrom.

I found an example here: http://www.hackerfactor.com/blog/index.php?/archives/552-Deep-Dive.html

<xmpMM:DerivedFrom
  stRef:instanceID="xmp.iid:048011740720681180839DD19BA24E58" 
  stRef:documentID="xmp.did:8F19CA801520681180A9CEE8487CF300" 
  stRef:originalDocumentID="11CD104525F505861ED0EC6DAC391558"/>
You can add this with exiv2, however the stRef: namespace will not be defined:
$ curl --silent http://dev.exiv2.org/attachments/download/805/DSC_7154.jpg > Stonehenge.jpg
$ exiv2 -M"set Xmp.xmpMM.DerivedFrom 'stRef:instanceID="xmp.iid:048011740720681180839DD19BA24E58" \
    stRef:documentID="xmp.did:8F19CA801520681180A9CEE8487CF300" \
    stRef:originalDocumentID="11CD104525F505861ED0EC6DAC391558"'" Stonehenge.jpg 
$ exiv2 -pX Stonehenge.jpg | xmllint -pretty 2 -
<?xml version="1.0"?>
<?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
        xmlns:xmp="http://ns.adobe.com/xap/1.0/" 
        xmlns:dc="http://purl.org/dc/elements/1.1/" 
        xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" 
        rdf:about="" 
        xmp:Rating="0" 
        xmp:ModifyDate="2015-07-16T20:25:28+01:00" 
        xmpMM:DerivedFrom="stRef:instanceID=xmp.iid:048011740720681180839DD19BA24E58 stRef:documentID=xmp.did:8F19CA801520681180A9CEE8487CF300 stRef:originalDocumentID=11CD104525F505861ED0EC6DAC391558" 
      > <dc:description
        > <rdf:Alt
          > <rdf:li
              xml:lang="x-default" 
            >Classic View</rdf:li
          > </rdf:Alt
        > </dc:description
      > </rdf:Description
    > </rdf:RDF
  > </x:xmpmeta
>
<?xpacket
end="w"?>
$ 
According to the Adobe Spec (Part 2), page 28, DerivedFrom is a ResourceRef. http://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMPSpecificationPart2.pdf

ResourceRef is defined on page 15 as:

The field namespace URI is http://ns.adobe.com/xap/1.0/sType/ResourceRef#
The preferred field namespace prefix is stRef
I've registered the stRef namespace (from the Adobe spec) and added a dummy tag to ensure stRef 'sticks' then added xmpMM.DerivedFrom attribute.
$ curl --silent curl http://dev.exiv2.org/attachments/download/805/DSC_7154.jpg > Stonehenge.jpg
$ exiv2 -M"reg stRef http://ns.adobe.com/xap/1.0/sType/ResourceRef#" -M"set Xmp.stRef.dummy dummy" -M"set Xmp.xmpMM.DerivedFrom 'stRef:instanceID="xmp.iid:048011740720681180839DD19BA24E58" stRef:documentID="xmp.did:8F19CA801520681180A9CEE8487CF300" stRef:originalDocumentID="11CD104525F505861ED0EC6DAC391558"'" Stonehenge.jpg
$ exiv2 -pX Stonehenge.jpg  | xmllint -pretty 2 -
<?xml version="1.0"?>
<?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
        xmlns:xmp="http://ns.adobe.com/xap/1.0/" 
        xmlns:dc="http://purl.org/dc/elements/1.1/" 
        xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#" 
        xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" 
        rdf:about="" 
        xmp:Rating="0" 
        xmp:ModifyDate="2015-07-16T20:25:28+01:00" 
        stRef:dummy="dummy" 
        xmpMM:DerivedFrom="stRef:instanceID=xmp.iid:048011740720681180839DD19BA24E58 stRef:documentID=xmp.did:8F19CA801520681180A9CEE8487CF300 stRef:originalDocumentID=11CD104525F505861ED0EC6DAC391558" 
      > <dc:description
        > <rdf:Alt
          > <rdf:li
              xml:lang="x-default" 
            >Classic View</rdf:li
          > </rdf:Alt
        > </dc:description
      > </rdf:Description
    > </rdf:RDF
  > </x:xmpmeta
>
<?xpacket
end="w"?>
$ 
I was a little surprised that I had to define the dummy to make the namespace 'stick'.
I was able to delete Xmp.stRef.dummy, however that also removed namespace definition xmlns:stRef=""
My feeling is that XMPsdk removes unused namepaces from its namespace registry.
So the Xmp.stRef.dummy tag is necessary for the version of XMPsdk being used by libexiv2.
Perhaps Andreas or Alan can add a comment about this.

RE: Xmp.xmpMM.DerivedFrom - Added by Alan Pater over 6 years ago

A couple of observations:

First: it looks like we are missing the stRef namespace as well as others. I'll go through the XMP spec and add them to exiv2. In the meantime, dynamically registering those namespaces works, as Robin demonstrates.

Second: stRef should be nested under xmpMM. Perhaps something like

exiv2 -M"set Xmp.xmpMM.DerivedFrom/stRef:instanceID="xmp.iid:048011740720681180839DD19BA24E58" \
    Xmp.xmpMM.DerivedFrom/stRef:documentID="xmp.did:8F19CA801520681180A9CEE8487CF300" \
    Xmp.xmpMM.DerivedFrom/stRef:originalDocumentID="11CD104525F505861ED0EC6DAC391558"'" Stonehenge.jpg

The sample image has:

Xmp.xmpMM.DerivedFrom                        XmpText     0  type="Struct" 
Xmp.xmpMM.DerivedFrom/stRef:instanceID       XmpText    40  xmp.iid:048011740720681180839DD19BA24E58
Xmp.xmpMM.DerivedFrom/stRef:documentID       XmpText    40  xmp.did:8F19CA801520681180A9CEE8487CF300
Xmp.xmpMM.DerivedFrom/stRef:originalDocumentID XmpText    32  11CD104525F505861ED0EC6DAC391558

RE: Xmp.xmpMM.DerivedFrom - Added by Alan Pater over 6 years ago

Correction. exiv2 does have stRef and the other structures registered. There is no need to manually register those namespaces.

http://dev.exiv2.org/projects/exiv2/repository/entry/trunk/src/properties.cpp#L146

Example working command line is:

exiv2 -M"set Xmp.xmpMM.DerivedFrom/stRef:instanceID 'xmp.iid:048011740720681180839DD19BA24E58'"  \
      -M"set Xmp.xmpMM.DerivedFrom/stRef:documentID 'xmp.did:8F19CA801520681180A9CEE8487CF300'"  \
      -M"set Xmp.xmpMM.DerivedFrom/stRef:originalDocumentID '11CD104525F505861ED0EC6DAC391558'" Stonehenge.jpg

RE: Xmp.xmpMM.DerivedFrom - Added by Robin Mills over 6 years ago

Brilliant work, Alan. This team-work stuff really works. Thanks. May I ask you to update the man page with this example. I'm sure this will be very helpful to another user.

Another observation about this. It seems namespaces are only listed in the XMP when used. So, stRef is only listed when used.

$ curl --silent http://dev.exiv2.org/attachments/download/805/DSC_7154.jpg > Stonehenge.jpg
$ exiv2 -vV -g svn
exiv2 0.25 001900 (64 bit build)
svn=3883
exiv2 -pX Stonehenge.jpg | xmllint -pretty 2 -
<?xml version="1.0"?>
<?xpacket
begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<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
        xmlns:xmp="http://ns.adobe.com/xap/1.0/" 
        xmlns:dc="http://purl.org/dc/elements/1.1/" 
        rdf:about="" 
        xmp:Rating="0" 
        xmp:ModifyDate="2015-07-16T20:25:28+01:00" 
      > <dc:description
        > <rdf:Alt
          > <rdf:li
              xml:lang="x-default" 
            >Classic View</rdf:li
          > </rdf:Alt
        > </dc:description
      > </rdf:Description
    > </rdf:RDF
  > </x:xmpmeta
>
<?xpacket
end="w"?>
Name space xmpMM and stRef have not been listed. Now update the XMP using your beautiful command line and they are listed:
$ exiv2 -M"set Xmp.xmpMM.DerivedFrom/stRef:instanceID 'xmp.iid:048011740720681180839DD19BA24E58'"  \
        -M"set Xmp.xmpMM.DerivedFrom/stRef:documentID 'xmp.did:8F19CA801520681180A9CEE8487CF300'"  \
        -M"set Xmp.xmpMM.DerivedFrom/stRef:originalDocumentID '11CD104525F505861ED0EC6DAC391558'" Stonehenge.jpg
$ exiv2 -pX Stonehenge.jpg | xmllint -pretty 2 -
<?xml version="1.0"?>
<?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
        xmlns:xmp="http://ns.adobe.com/xap/1.0/" 
        xmlns:dc="http://purl.org/dc/elements/1.1/" 
        xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"                 <!-- <-- appears by magic -->
        xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#"  <!-- <-- appears by magic -->
        rdf:about="" 
        xmp:Rating="0" 
        xmp:ModifyDate="2015-07-16T20:25:28+01:00" 
      > <dc:description
        > <rdf:Alt
          > <rdf:li
              xml:lang="x-default" 
            >Classic View</rdf:li
          > </rdf:Alt
        > </dc:description
      > <xmpMM:DerivedFrom
          stRef:instanceID="xmp.iid:048011740720681180839DD19BA24E58" 
          stRef:documentID="xmp.did:8F19CA801520681180A9CEE8487CF300" 
          stRef:originalDocumentID="11CD104525F505861ED0EC6DAC391558" 
      /> </rdf:Description
    > </rdf:RDF
  > </x:xmpmeta
>
<?xpacket
end="w"?>
$ 
Perhaps it would be helpful to list these namespaces in the man page. And another possibility is to print them to stdout when using exiv2 -vV (--verbose --version). The command exiv2 -vV -g xmlns would filter to only reveal with information.

RE: Xmp.xmpMM.DerivedFrom - Added by Robin Mills about 6 years ago

r3891 deals with #640 and enumerates the XMP namespace register using exiv2 --verbose --version

    (1-6/6)