Library examples - Looking for an image that contains meta data from this page - Example 5: xmpsample.cpp
Added by Colin K over 3 years ago
[[http://www.exiv2.org/examples.html]] Example 5: xmpsample.cpp
Example 5 on this page includes details about adding multiple Job Name and Job Role. I do not see this meta data in any of the images on this page.
Is there an image that includes the data below?
Xmp.xmpBJ.JobRef[1]/stJob:name XmpText 14 Birthday party Xmp.xmpBJ.JobRef[1]/stJob:role XmpText 12 Photographer Xmp.xmpBJ.JobRef[2]/stJob:name XmpText 16 Wedding ceremony Xmp.xmpBJ.JobRef[2]/stJob:role XmpText 8 Best man
Thanks ColinK
Replies (1)
RE: Library examples - Looking for an image that contains meta data from this page - Example 5: xmpsample.cpp - Added by Robin Mills over 3 years ago
In 10 years of contributing to Exiv2, I've never noticed this sample! Good News: I believe it's working as documented. It's possibly not working in the way in which you expect (as I will explain).
I've build it (on the Mac):
$ git clone https://github.com/exiv2/exiv2
$ cd exiv2
$ mkdir build ; cd build ; cmake .. ; make
$ bin/xmpsample
584 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ bin/xmpsample
Xmp.dc.source XmpText 13 xmpsample.cpp
Xmp.dc.subject XmpBag 2 Palmtree, Rubbertree
Xmp.dc.title LangAlt 2 lang="en-US" Sunset on the beach, lang="de-DE" Sonnenuntergang am Strand
Xmp.dc.one XmpText 2 -1
Xmp.dc.two XmpText 6 3.1415
Xmp.dc.three XmpText 3 5/7
Xmp.dc.four XmpText 3 255
Xmp.dc.five XmpText 3 256
Xmp.dc.six XmpText 5 False
Xmp.dc.seven XmpText 5 Seven
Xmp.dc.format XmpText 10 image/jpeg
Xmp.dc.creator XmpSeq 3 1) The first creator, 2) The second creator, 3) And another one
Xmp.dc.description LangAlt 2 lang="x-default" Hello, World, lang="de-DE" Hallo, Welt
Xmp.tiff.ImageDescription LangAlt 2 lang="x-default" TIFF image description, lang="de-DE" TIFF Bildbeschreibung
Xmp.ns.myProperty XmpText 7 myValue
Xmp.xmpDM.videoFrameSize/stDim:w XmpText 2 16
Xmp.xmpDM.videoFrameSize/stDim:h XmpText 1 9
Xmp.xmpDM.videoFrameSize/stDim:unit XmpText 4 inch
Xmp.dc.publisher XmpBag 1 James Bond
Xmp.dc.publisher[1]/?ns:role XmpText 12 secret agent
Xmp.dc.creator[2]/?ns:role XmpText 10 programmer
Xmp.xmpBJ.JobRef XmpText 0 type="Bag"
Xmp.xmpBJ.JobRef[1]/stJob:name XmpText 14 Birthday party
Xmp.xmpBJ.JobRef[1]/stJob:role XmpText 12 Photographer
Xmp.xmpBJ.JobRef[2]/stJob:name XmpText 16 Wedding ceremony
Xmp.xmpBJ.JobRef[2]/stJob:role XmpText 8 Best man
Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCity XmpText 12 Kuala Lumpur
Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiAdrCtry XmpText 8 Malaysia
Xmp.iptc.CreatorContactInfo/Iptc4xmpCore:CiUrlWork XmpText 20 http://www.exiv2.org
<?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:dc="http://purl.org/dc/elements/1.1/"
xmlns:ns="myNamespace/"
xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
xmlns:xmpDM="http://ns.adobe.com/xmp/1.0/DynamicMedia/"
xmlns:stDim="http://ns.adobe.com/xap/1.0/sType/Dimensions#"
xmlns:xmpBJ="http://ns.adobe.com/xap/1.0/bj/"
xmlns:stJob="http://ns.adobe.com/xap/1.0/sType/Job#"
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
dc:source="xmpsample.cpp"
dc:one="-1"
dc:two="3.1415"
dc:three="5/7"
dc:four="255"
dc:five="256"
dc:six="False"
dc:seven="Seven"
dc:format="image/jpeg"
ns:myProperty="myValue">
<dc:subject>
<rdf:Bag>
<rdf:li>Palmtree</rdf:li>
<rdf:li>Rubbertree</rdf:li>
</rdf:Bag>
</dc:subject>
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="en-US">Sunset on the beach</rdf:li>
<rdf:li xml:lang="de-DE">Sonnenuntergang am Strand</rdf:li>
</rdf:Alt>
</dc:title>
<dc:creator>
<rdf:Seq>
<rdf:li>1) The first creator</rdf:li>
<rdf:li rdf:parseType="Resource">
<rdf:value>2) The second creator</rdf:value>
<ns:role>programmer</ns:role>
</rdf:li>
<rdf:li>3) And another one</rdf:li>
</rdf:Seq>
</dc:creator>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">Hello, World</rdf:li>
<rdf:li xml:lang="de-DE">Hallo, Welt</rdf:li>
</rdf:Alt>
</dc:description>
<dc:publisher>
<rdf:Bag>
<rdf:li rdf:parseType="Resource">
<rdf:value>James Bond</rdf:value>
<ns:role>secret agent</ns:role>
</rdf:li>
</rdf:Bag>
</dc:publisher>
<tiff:ImageDescription>
<rdf:Alt>
<rdf:li xml:lang="x-default">TIFF image description</rdf:li>
<rdf:li xml:lang="de-DE">TIFF Bildbeschreibung</rdf:li>
</rdf:Alt>
</tiff:ImageDescription>
<xmpDM:videoFrameSize
stDim:w="16"
stDim:h="9"
stDim:unit="inch"/>
<xmpBJ:JobRef>
<rdf:Bag>
<rdf:li
stJob:name="Birthday party"
stJob:role="Photographer"/>
<rdf:li
stJob:name="Wedding ceremony"
stJob:role="Best man"/>
</rdf:Bag>
</xmpBJ:JobRef>
<Iptc4xmpCore:CreatorContactInfo
Iptc4xmpCore:CiAdrCity="Kuala Lumpur"
Iptc4xmpCore:CiAdrCtry="Malaysia"
Iptc4xmpCore:CiUrlWork="http://www.exiv2.org"/>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
...
<?xpacket end="w"?>
585 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ bin/xmpsample | cet
bbedit "/var/tmp/tmp.0.tgL3U7" 2>/dev/null >/dev/null
586 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ The code is managing XMP in memory. It doesn't write it to an image file! So, it creates the object Exiv2::XmpMeta xmpData on the stack and proceeds to update it. At the end, it encodes the data (as XML) and reports.
This is an unusual use case for Exiv2. The more common pattern (see samples/exifprint.cpp) is to use the ImageFactory to open an image, and call image->readMetadata(); Exiv2::ExifData &xmpData = image-xmpData(); to obtain xmpData. You can modify the xmpData (in memory) and store changes by calling image->writeMetadata().
Thank You for raising this subject on the forum. If you're puzzled by my explanation, I'm happy to discuss this further. Thank You for using Exiv2.