changeset 891:24fc302f9076

Work around Pillow IndexError on certain images. See Issue #82.
author Brian Neal <bgneal@gmail.com>
date Mon, 16 Feb 2015 18:58:49 -0600
parents df09f327e1b9
children 79a71b9d0a2a
files core/image.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/core/image.py	Mon Feb 16 18:39:33 2015 -0600
+++ b/core/image.py	Mon Feb 16 18:58:49 2015 -0600
@@ -102,7 +102,13 @@
 
     """
     if hasattr(im, '_getexif'):
-        exif = im._getexif()
+        try:
+            exif = im._getexif()
+        except IndexError:
+            # Work around issue seen in Pillow
+            # https://github.com/python-pillow/Pillow/issues/518
+            exif = None
+
         if exif and ORIENT_TAG in exif:
             orientation = exif[ORIENT_TAG]
             func = ORIENT_FUNCS.get(orientation)