Browse Source

Catch warnings when reading EXIF data

pull/304/merge
Simon Conseil 6 years ago
parent
commit
fbdac965a9
  1. 7
      sigal/image.py

7
sigal/image.py

@ -222,11 +222,16 @@ def get_exif_data(filename):
img = _read_image(filename)
try:
exif = img._getexif() or {}
with warnings.catch_warnings(record=True) as caught_warnings:
exif = img._getexif() or {}
except ZeroDivisionError:
logger.warning('Failed to read EXIF data.')
return None
for w in caught_warnings:
logger.warning(f'PILImage reported a warning for file {filename}\n'
f'{w.category}: {w.message}')
data = {TAGS.get(tag, tag): value for tag, value in exif.items()}
if 'GPSInfo' in data:

Loading…
Cancel
Save