comparison core/image.py @ 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 36d988b800c2
children
comparison
equal deleted inserted replaced
890:df09f327e1b9 891:24fc302f9076
100 was oriented and False otherwise. image is either a new transformed image or 100 was oriented and False otherwise. image is either a new transformed image or
101 the original image instance. 101 the original image instance.
102 102
103 """ 103 """
104 if hasattr(im, '_getexif'): 104 if hasattr(im, '_getexif'):
105 exif = im._getexif() 105 try:
106 exif = im._getexif()
107 except IndexError:
108 # Work around issue seen in Pillow
109 # https://github.com/python-pillow/Pillow/issues/518
110 exif = None
111
106 if exif and ORIENT_TAG in exif: 112 if exif and ORIENT_TAG in exif:
107 orientation = exif[ORIENT_TAG] 113 orientation = exif[ORIENT_TAG]
108 func = ORIENT_FUNCS.get(orientation) 114 func = ORIENT_FUNCS.get(orientation)
109 if func: 115 if func:
110 return (True, func(im)) 116 return (True, func(im))