Skip to content

Commit

Permalink
widgest.get_attrs should try to use 'image' as a file, but not crash …
Browse files Browse the repository at this point in the history
…if not
  • Loading branch information
fgmacedo committed Apr 14, 2016
1 parent 1de79ec commit 49ebabf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions image_cropping/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ def thumbnail_url(image_path):
def get_attrs(image, name):
try:
# TODO test case
# If the image file has already been closed, open it
if image.closed:
image.open()

# Seek to the beginning of the file. This is necessary if the
# image has already been read using this file handler
image.seek(0)
try:
# try to use image as a file
# If the image file has already been closed, open it
if image.closed:
image.open()

# Seek to the beginning of the file. This is necessary if the
# image has already been read using this file handler
image.seek(0)
except:
pass

try:
# open image and rotate according to its exif.orientation
Expand Down

0 comments on commit 49ebabf

Please sign in to comment.