diff core/image_uploader.py @ 837:234726f5a47a

For issue #74, re-orient uploaded images if necessary.
author Brian Neal <bgneal@gmail.com>
date Sat, 04 Oct 2014 13:43:22 -0500
parents df2799f725d8
children ee47122d6277
line wrap: on
line diff
--- a/core/image_uploader.py	Thu Oct 02 19:07:07 2014 -0500
+++ b/core/image_uploader.py	Sat Oct 04 13:43:22 2014 -0500
@@ -12,6 +12,7 @@
 from PIL import Image
 
 from core.functions import temp_open
+from core.image import orient_image
 
 
 logger = logging.getLogger(__name__)
@@ -63,6 +64,12 @@
             temp_file.write(chunk)
         temp_file.close()
 
+        # Re-orient if necessary
+        image = Image.open(temp_name)
+        changed, image = orient_image(image)
+        if changed:
+            image.save(temp_name)
+
         # Resize image if necessary
         if new_size:
             image = Image.open(temp_name)