#!/usr/bin/python # -*- encoding: utf-8 -*- # # exif-set-datetime - sets date and time in EXIF # # Usage: exif-set-datetime "YYYY:MM:DD HH:mm:ss" file.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 DateTimeTags = ('Exif.Image.DateTime', 'Exif.Photo.DateTimeOriginal') # Parse arguments if len(sys.argv) != 3: print "Usage: exif-set-datetime \"YYYY:MM:DD HH:mm:ss\" file.jpg" sys.exit(1) datetime = sys.argv[1] jpg_file = sys.argv[2] # Extract GPSInfo tags from file_with_gpsinfo im = pyexiv2.Image(jpg_file) im.readMetadata() for tag in DateTimeTags: im[tag] = datetime im.writeMetadata() sys.exit(0)