gexiv2

gexiv2 is a GObject-based wrapper around the Exiv2 library. It makes the basic features of Exiv2 available to GNOME applications. Thanks to GObject Introspection support that was added in 0.5, GExiv2 now has excellent support for Python 2 & 3, and can also be accessed by any other programming language that supports GI.

The current release of gexiv2 is gexiv 0.6.1, released March 19, 2013.

Shotwell requires gexiv2 as a dependency.

Yorba inherited the initial gexiv2 code from Mike Gemuende (his initial repository is here). Note that Shotwell will not work with his 0.0.1 version.

Mailing list

Send a message with a subject: of subscribe to or go to http://lists.yorba.org/cgi-bin/mailman/listinfo/gexiv2.

Building and installing

To build the current version of gexiv2, you will first need to install libexiv2 version 0.21 or better, including the header files and other files needed for building programs that use this library. Both Ubuntu 11.04 Natty Narwhal (or later) and Fedora 15 (or later) contain sufficiently recent versions in their repositories. On Ubuntu, you can run this command:

$ sudo apt-get install libexiv2-dev

Alternatively, you can download the latest exiv2 source from http://www.exiv2.org/download.html and build exiv2 yourself.

There are two ways to get the gexiv2 source code:

  • Download a source tarball of the latest stable release: gexiv2 0.6 .
  • For the latest code, check out the source from our Git server:
git clone git://git.yorba.org/gexiv2

Note that in order to build from trunk, you'll need to update your Exiv2 installation to version 0.21 or later.

To build, run the following commands:

$ ./configure --enable-introspection

$ make

$ make install

You may need to execute @make install@ as root (i.e. sudo make install).

Vala support

A Vala VAPI file for gexiv2 is maintained in the source tree. Vala developers who make changes to the library and wish to check it out in their own project should (a) make any necessary changes to vapi/gexiv2.metadata and (b) run make vapi and make install-vapi before building their application.

Note that make vapi only works after gexiv2 has been installed; the VAPI it generates does not reflect the state of the local source tree.

When #6169 is completed, gexiv2 will distribute a GObject Introspection file rather than a VAPI, which is more convenient and allows other languages to easily bind to gexiv2.

Python support

Here is a short example of how to use GExiv2 in Python. This will work equally well with either Python 2 or 3, which makes GExiv2 an excellent replacement for pyexiv2, which only supports Python 2. Developers who wish to port their python applications from 2 to 3 will want to port from pyexiv2 to GExiv2 first, and then from 2 to 3 afterwards.

#!/usr/bin/python3

from gi.repository import GExiv2

exif = GExiv2.Metadata('IMG_1234.JPG')

# longitude, latitude, altitude
exif.set_gps_info(-79.3969702721, 43.6295057244, 76)

# Using dict notation like this reads/writes RAW string values
# into the EXIF data, with no modification/interpolation by GExiv2.
# Refer to GExiv2.py to see what kind of convenience methods are
# supplied for setting/getting non-string values.
IPTC = 'Iptc.Application2.'
exif[IPTC + 'City'] = 'Toronto'
exif[IPTC + 'ProvinceState'] = 'Ontario'
exif[IPTC + 'CountryName'] = 'Canada'

exif.save_file()

Also available is a slightly larger example on github, and you can also refer to GottenGeography's code, which was the first nontrivial python application ported to GExiv2.

Bugs and limitations

Please visit our gexiv2 ticketing system.

Release history

A gexiv2 release history is available here.

Check out the gexiv2 download directory for a full listing of releases.