From 2fc5aa0859d2747b2a0b2c8fd630a2c2bf31f7a8 Mon Sep 17 00:00:00 2001 From: lian Date: Mon, 5 Sep 2016 13:48:19 +0800 Subject: [PATCH] update get image's exif info function --- seahub/thumbnail/utils.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/seahub/thumbnail/utils.py b/seahub/thumbnail/utils.py index 87c255019c..7fe2c05883 100644 --- a/seahub/thumbnail/utils.py +++ b/seahub/thumbnail/utils.py @@ -27,19 +27,12 @@ def get_rotated_image(image): # get image's exif info exif = {} - if image._getexif(): - exif = { - ExifTags.TAGS[k]: v - for k, v in image._getexif().items() - if k in ExifTags.TAGS - } - - # get Orientation info from exif - if exif.has_key('Orientation'): - orientation = exif['Orientation'] - else: - orientation = 1 + try: + exif = image._getexif() + except Exception: + return image + orientation = exif.get(0x0112) # rotate image according to Orientation info if orientation == 2: # Vertical image