changed order - rotating resized image
This commit is contained in:
@@ -90,15 +90,9 @@ def handle_uploaded_image(i):
|
||||
break
|
||||
exif=dict(image._getexif().items())
|
||||
|
||||
if exif[orientation] == 3:
|
||||
image=image.rotate(180, expand=True)
|
||||
elif exif[orientation] == 6:
|
||||
image=image.rotate(270, expand=True)
|
||||
elif exif[orientation] == 8:
|
||||
image=image.rotate(90, expand=True)
|
||||
except (AttributeError, KeyError, IndexError):
|
||||
# cases: image don't have getexif
|
||||
pass
|
||||
exif = {'orientation':0}
|
||||
|
||||
if image.mode not in ("L", "RGB"):
|
||||
image = image.convert("RGB")
|
||||
@@ -108,6 +102,12 @@ def handle_uploaded_image(i):
|
||||
hsize = int((float(image.size[1])*float(wpercent)))
|
||||
image = image.resize((basewidth,hsize), Image.ANTIALIAS)
|
||||
|
||||
if exif[orientation] == 3:
|
||||
image=image.rotate(180, expand=True)
|
||||
elif exif[orientation] == 6:
|
||||
image=image.rotate(270, expand=True)
|
||||
elif exif[orientation] == 8:
|
||||
image=image.rotate(90, expand=True)
|
||||
|
||||
filename = hashlib.md5(imagefile.getvalue()).hexdigest()+'.jpg'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user