Correct support for JPG images
This commit is contained in:
parent
e9038bdb76
commit
bd0b9aca94
@ -10,18 +10,24 @@ from PIL.ExifTags import TAGS
|
||||
|
||||
import os
|
||||
|
||||
os.chdir('photos')
|
||||
path = 'photos'
|
||||
|
||||
os.chdir(path)
|
||||
|
||||
names = []
|
||||
dates = []
|
||||
|
||||
for fileName in sorted(os.listdir()):
|
||||
image = Image.open(fileName)
|
||||
try:
|
||||
image = Image.open(fileName)
|
||||
except:
|
||||
# Skip raw images.
|
||||
continue
|
||||
imageExif = image.getexif()
|
||||
dateTimeKey = list(TAGS.keys())[list(TAGS.values()).index('DateTime')]
|
||||
dateTime = imageExif[dateTimeKey]
|
||||
names += [fileName.replace('DSC0', '').replace('.JPG', '')]
|
||||
dates += [dateTime[:(-1 if fileName.endswith('.tif') else 0)]]
|
||||
dates += [dateTime[:(-1 if fileName.endswith('.tif') else len(dateTime))]]
|
||||
|
||||
# Convert date strings to datetime
|
||||
dates = [datetime.strptime(d, "%Y:%m:%d %H:%M:%S") for d in dates]
|
||||
|
Loading…
x
Reference in New Issue
Block a user