Created
July 15, 2018 19:52
-
-
Save tuaplicacionpropia/db4fa7f5026a1d2eee37ef4ed31c0eb9 to your computer and use it in GitHub Desktop.
Get Date of Photo/Image
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 python2.7 | |
import sys | |
import locale | |
from PIL import Image | |
from PIL.ExifTags import TAGS | |
from datetime import datetime | |
def get_exif(fn): | |
ret = {} | |
i = Image.open(fn) | |
info = i._getexif() | |
for tag, value in info.items(): | |
decoded = TAGS.get(tag, tag) | |
ret[decoded] = value | |
return ret | |
#'DateTime': u'2017:12:21 10:52:44' | |
def get_fecha (fn): | |
result = None | |
data = get_exif(fn) | |
key = 'DateTime' | |
if key in data: | |
dateTxt = data[key] | |
datetime_object = datetime.strptime(dateTxt, '%Y:%m:%d %H:%M:%S') | |
locale.setlocale(locale.LC_ALL, 'es_ES.UTF-8') | |
result = datetime_object.strftime("%A %-d de %B de %Y") | |
return result | |
print get_fecha(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment