__doctype__ __header4__ __navbar__

Example 1: exifprint.cpp

This is a very simple program to read and print the Exif metadata of an image. Go to Example2 to see how the output looks like.

__example1__

 


Example 2: addmoddel.cpp

Sample usage of high-level Exiv2 library calls to add, modify and delete Exif metadata.

__example2__

 

Using the print function from Example1 shows the following Exif tags in the image. Note the tag Exif.Image.ExifTag: It is required by the Exif standard because the metadata contains an Exif.Photo.* tag and is automatically added by Exiv2 to ensure that the Exif structure is valid.

$ exifprint img_2158.jpg
Exif.Image.Model                  0x0110 Ascii       7  Test 1
Exif.Image.SamplesPerPixel        0x0115 Short       1  162
Exif.Image.XResolution            0x011a SLong       1  -2
Exif.Image.YResolution            0x011b SRational   1  -2/3
Exif.Image.ExifTag                0x8769 Long        1  89
Exif.Photo.DateTimeOriginal       0x9003 Ascii      20  2000:12:31 23:59:59
    
Image containing the Exif metadata from example 2

Image with the Exif metadata from example 2


Example 3: iptcprint.cpp

This is a very simple program to read and print the IPTC metadata of an image.

__example3__

 

$ iptcprint smiley1.jpg
Iptc.Application2.Headline              0x0069 String     17  The headline I am
Iptc.Application2.Keywords              0x0019 String     19  Yet another keyword
Iptc.Application2.DateCreated           0x0037 Date        8  2004-08-03
Iptc.Application2.Urgency               0x000a String      5  very!
Iptc.Envelope.ModelVersion              0x0000 Short       1  42
Iptc.Envelope.TimeSent                  0x0050 Time       11  14:41:00-05:00
Iptc.Application2.RasterizedCaption     0x007d Undefined   8  230 42 34 2 90 84 23 146
Iptc.0x0009.0x0001                      0x0001 String      9  Who am I?
    
Sample image with the IPTC data from example 3

Image with the IPTC data
from examples 3 & 4


Example 4: iptceasy.cpp

This shows the quickest way to access, set or modify IPTC metadata, which is similar to how std::map works. The sample program writes the IPTC data to a file. Example 3, above, has the image with this IPTC data.

__example4__

 


Example 5: xmpsample.cpp

Sample (test) usage of high level XMP classes. This example shows various aspects of setting XMP metadata, including complex types. See also Example 2: addmoddel.cpp

__example5__

 

The resulting XMP Exiv2 metadata and XMP packet is below. The same can be achieved with a set of commands to the Exiv2 command line tool.

$ xmpsample
Xmp.dc.source                                XmpText    13  xmpsample.cpp
Xmp.dc.subject                               XmpBag      2  Palmtree, Rubbertree
Xmp.dc.title                                 LangAlt     2  lang="de-DE" Sonnenuntergang am Strand, lang="en-US" Sunset on the beach
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.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

<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.1.1-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:xapBJ="http://ns.adobe.com/xap/1.0/bj/"
    xmlns:stJob="http://ns.adobe.com/xap/1.0/sType/Job#"
   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">
   <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="de-DE">Sonnenuntergang am Strand</rdf:li>
     <rdf:li xml:lang="en-US">Sunset on the beach</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"/>
   <xapBJ:JobRef>
    <rdf:Bag>
     <rdf:li
      stJob:name="Birthday party"
      stJob:role="Photographer"/>
     <rdf:li
      stJob:name="Wedding ceremony"
      stJob:role="Best man"/>
    </rdf:Bag>
   </xapBJ:JobRef>
  </rdf:Description>
 </rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
__footer__ __bootstrap__