Created
April 30, 2015 23:15
-
-
Save openfly/22622b497856ea069ccc to your computer and use it in GitHub Desktop.
an example of how to set some exif data on an image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from gi.repository import GExiv2 | |
import pprint | |
exif = GExiv2.Metadata('test.jpg') | |
lat = exif.get_gps_latitude() | |
lon = exif.get_gps_longitude() | |
print "Latitude: %s" % lat | |
print "Longitude: %s" % lon | |
# longitude, latitude, altitude | |
exif.set_gps_info(-41.3969702721, 122.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'] = 'Vatican City' | |
exif[IPTC + 'ProvinceState'] = 'The Vatican' | |
exif[IPTC + 'CountryName'] = 'The Vatican' | |
exif.save_file() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment