Exiv2 - Exif and IPTC metadata library and tools
Author: Andreas Huggel
Description: Open source Exif and IPTC metadata library and tools with Exif MakerNote and read/write support
Keywords: exif, iptc, metadata, makernote, manipulation, manipulate, read and write, write, change, update, jpeg, jpg, ifd, image file directory, thumbnail, thumbnails, tag, tags, canon, fujifilm, sigma/foveon, nikon, open source, opensource, huggel, andreas, andreas huggel

- Main Page
- Namespaces
- Classes
- Files
- Examples

# Getting started

## Namespaces

The Exiv2 library is made up of all elements defined in the Exiv2 namespace. The Action and Util namespaces are only used by the Exiv2 command line utility.

## Classes

The top-level class of the Exiv2 library is Exiv2::Image (don't let the components diagram below mislead you). Exiv2::Image defines the interface to access various image metadata. Derived from Exiv2::Image are the implementations of different image formats. Most applications will use Exiv2::ImageFactory to access images in files or memory, in which case the image format is transparent to them.

Exif and IPTC metadata is manipulated through the classes Exiv2::ExifData and Exiv2::IptcData. They hold a container of Exif and IPTC metadata, respectively, and define related methods to access and manipulate the metadata. The containers hold objects derived from Exiv2::Metadatum. Interface class Exiv2::Metadatum defines methods to access the information of one Exif tag or IPTC dataset. It models the tag data as a key and value pair. The abstract base class Exiv2::Key defines the interface for a key. Concrete keys implement Exif and IPTC keys. The abstract base class Exiv2::Value defines the interface to access tag information, from which concrete values are derived. The actual value used in a metadatum depends on the type of the Exif tag or IPTC dataset. It is usually determined when the Exif metadata is read from an image. It is also possible to manually create a Value and together with a key add it to an ExifData or IptcData container.

Top-level Exiv2 classes to access XMP metadata are Exiv2::XmpData, Exiv2::Xmpdatum and Exiv2::XmpKey. They work similar to the corresponding Exif and IPTC classes. The property-repository is Exiv2::XmpProperties. In addition to the expected new members, class Exiv2::Image also has an interface to access the raw XMP packet. All XMP value types are supported: Simple types, structures, arrays, property qualifiers and language alternatives. XMP properties are accessed through keys of the form "Xmp.<Prefix>.<PropertyPath>", where <Prefix> is the preferred (or rather, registered) prefix for a schema namespace and <PropertyPath> is the path of the XMP node. In its most basic form, to address simple properties, <PropertyPath> is the name of the property. In general, <PropertyPath> can be used to address any XMP node, including array items, structure fields qualifiers and deeply nested properties. Any properties in known namespaces are supported and additional namespaces can be registered. The specialized Exiv2 values Exiv2::XmpTextValue, Exiv2::XmpArrayValue and Exiv2::LangAltValue are provided to simplify the use of XMP properties. Note: Unlike Exif and IPTC tags, XMP properties do not have a tag number.

## Examples

There are several simple examples that demonstrate the basic use of Exiv2 functionality: Exifprint shows how the Exif data of an image can be read and written to the screen. Iptcprint is a similar example to print IPTC data. Addmoddel shows how to add, modify and delete Exif metadata. Exifcomment shows how to set the exif comment of an image. Xmpsample.cpp contains examples of how to set various types of XMP properties.
For more real-world code have a look at the implementation of the different actions of the Exiv2 utility (actions.cpp).

## Makernotes

Exif Makernote data can be accessed through ExifData in the same way as the standard Exif tags. In other words, for each entry of a known Makernote, there is a corresponding Metadatum in the ExifData container. The abstract base class Exiv2::MakerNote defines the Makernote interface. Subclass Exiv2::IfdMakerNote models makernotes encoded in IFD format. Implementing a new IFD makernote is straightforward. Implementing a new makernote that is not encoded in IFD format however, is more difficult. Please contact me if you have such a makernote specification and would like assistance adding it to Exiv2.

## IFD (Image File Directory)

Exiv2::Ifd is a generic low-level class that models an image file directory as defined by TIFF and used in the Exif standard. Exiv2::Ifd could be used to implement read only as well as read/write access to Exif (or TIFF) data without the overhead (and convenience) of Exiv2::ExifData.

## Components

The picture below shows the components that make up the Exiv2 library and how they depend on each other. Component names are the same as the basenames of their source files. Each component has its own header and source files.

### Exiv2 Components Diagram