Do not try to read EXIF data from a PNG file

This commit is contained in:
Felipe Martin 2018-09-29 23:56:57 +02:00
parent f13ac7e590
commit 295db2a5d2
Signed by: fmartingr
GPG Key ID: 716BC147715E716F
1 changed files with 6 additions and 3 deletions

View File

@ -92,9 +92,12 @@ class File:
modification date. Make sure your pictures are exported unmodified so the file attributes maintain their
original values for this to work.
"""
if self.is_image:
date, time = self.exif['EXIF DateTimeOriginal'].values.split()
return datetime(*(int(x) for x in date.split(':') + time.split(':')))
if self.is_image and 'png' not in self.path.lower():
try:
date, time = self.exif['EXIF DateTimeOriginal'].values.split()
return datetime(*(int(x) for x in date.split(':') + time.split(':')))
except KeyError:
pass
if self.is_video:
# Apple iPhone tag