Created
June 22, 2018 13:03
-
-
Save akagisho/6626aa24b9c321b9351684f0da76d84e to your computer and use it in GitHub Desktop.
This file contains hidden or 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/env python | |
import sys | |
import os | |
import stat | |
import datetime | |
import pyexiv2 | |
argvs = sys.argv | |
argc = len(argvs) | |
if (argc < 3): | |
print 'Usage: python %s filename YYYY:MM:DD HH:II:SS' % argvs[0] | |
quit() | |
filename = argvs[1] | |
yyyymmdd = argvs[2] | |
if (argc == 3): | |
hhiiss = '00:00:00' | |
else: | |
hhiiss = argvs[3] | |
date = yyyymmdd.split(':') | |
time = hhiiss.split(':') | |
image_date = datetime.datetime(int(date[0]), int(date[1]), int(date[2]), int(time[0]), int(time[1]), int(time[2])) | |
img = pyexiv2.ImageMetadata(filename) | |
img.read() | |
img['Exif.Photo.DateTimeOriginal'] = image_date | |
img.write() | |
print img['Exif.Photo.DateTimeOriginal'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment