git » galala » commit 0d59a5b

Correctly handle images without exif info

author Rodrigo Campos
2013-08-10 18:56:37 UTC
committer Rodrigo Campos
2013-08-13 08:59:16 UTC
parent 1c673aa0871a45a979445593eef281c727a8c847

Correctly handle images without exif info

If EXIF information is not present, we just skip the loops and save the
thumbnail without any rotation. This is the best we can do.

Signed-off-by: Rodrigo Campos <rodrigo@sdfg.com.ar>

galala +5 -1

diff --git a/galala b/galala
index ceea46c..1b7a25c 100755
--- a/galala
+++ b/galala
@@ -29,7 +29,11 @@ exif_rotations = {
 def resize_img(img, x, y, dst):
     "Resizes the given image, and saves it to dst."
     img = pil_image.open(img)
-    for k, v in img._getexif().items():
+    exif_items = []
+    if img._getexif() is not None:
+        exif_items = img._getexif().items()
+
+    for k, v in exif_items:
         if k in pil_exif.TAGS and pil_exif.TAGS[k] == 'Orientation':
             if v in exif_rotations:
                 img = img.rotate(exif_rotations[v],