#!/usr/bin/python # -*- encoding: utf-8 -*- # # exif-gps - Copies over GPSInfo tags. # # Usage: exif-cp-gps File_with_GPSInfo.jpg file.jpg [more.jpg ... files.jpg] # # Copyright (C) Miguel Ángel Vilela # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. import pyexiv2 import sys if len(sys.argv) < 3: print "Usage: exif-cp-gps File_with_GPSInfo.jpg file.jpg [more.jpg ... files.jpg]" sys.exit(1) file_with_gpsinfo = sys.argv[1] print file_with_gpsinfo jpg_files = sys.argv[2:] print jpg_files # Extract GPSInfo tags from file_with_gpsinfo im = pyexiv2.Image(file_with_gpsinfo) im.readMetadata() gps_tags = [tag for tag in im.exifKeys() if tag[:13] == 'Exif.GPSInfo.'] print "Got %s tags from %s" % (gps_tags, file_with_gpsinfo) for jpg in jpg_files: print "Setting tags on %s" % jpg out = pyexiv2.Image(jpg) out.readMetadata() for tag in gps_tags: out[tag] = im[tag] out.writeMetadata() sys.exit(0)