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.
1 #!/usr/bin/python3 2 3 import gi 4 gi.require_version('GExiv2', '0.10') 5 from gi.repository import GExiv2 6 7 exif = GExiv2.Metadata('IMG_1234.JPG') 8 9 # longitude, latitude, altitude 10 exif.set_gps_info(-79.3969702721, 43.6295057244, 76) 11 12 # Using dict notation like this reads/writes RAW string values 13 # into the EXIF data, with no modification/interpolation by GExiv2. 14 # Refer to GExiv2.py to see what kind of convenience methods are 15 # supplied for setting/getting non-string values. 16 IPTC = 'Iptc.Application2.' 17 exif[IPTC + 'City'] = 'Toronto' 18 exif[IPTC + 'ProvinceState'] = 'Ontario' 19 exif[IPTC + 'CountryName'] = 'Canada' 20 21 exif.save_file()
If you're having trouble with initializing GExiv2.Metadata, see Simon Feltman's debugging tips on Launchpad.