- if use_exif:
- try:
- with PIL.Image.open(file_path) as image:
- exif = image._getexif()
- if exif and 36867 in exif:
- return int( datetime.datetime
- .strptime(exif[36867], '%Y:%m:%d %H:%M:%S')
- .timestamp() )
- except PIL.UnidentifiedImageError:
- pass
+ if use_exif and _is_media_file(file_path, types=['image']):
+ with PIL.Image.open(file_path) as image:
+ exif = image._getexif()
+ if exif and 36867 in exif:
+ return int( datetime.datetime
+ .strptime(exif[36867], '%Y:%m:%d %H:%M:%S')
+ .timestamp() )