Skip to content

Commit

Permalink
Exception handled ageitgey#1
Browse files Browse the repository at this point in the history
  • Loading branch information
var-nan committed May 25, 2021
1 parent 3b353cf commit ff89637
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion image_to_numpy/src.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,18 @@ def load_image_file(file, mode='RGB'):

if hasattr(PIL.ImageOps, 'exif_transpose'):
# Very recent versions of PIL can do exit transpose internally
img = PIL.ImageOps.exif_transpose(img)

# PIL.ImageOps.exif_transpose() is raising an exception.
# perform exif_transpose() manually until it gets fixed.
try:

img = PIL.ImageOps.exif_transpose(img)

except:

img = PIL.Image.open(file)
img = exif_transpose(img)

else:
# Otherwise, do the exif transpose ourselves
img = exif_transpose(img)
Expand Down

0 comments on commit ff89637

Please sign in to comment.