From 129c8b736dce8ad9a7364cf4c32fd8a8ebd5ffcb Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Tue, 30 Jul 2013 17:32:13 +0200 Subject: [PATCH] Preserve EXIF tags when resizing --- sigal/image.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sigal/image.py b/sigal/image.py index 94a98f4..bba8634 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -43,6 +43,15 @@ def generate_image(source, outname, size, format, options=None, img = PILImage.open(source) original_format = img.format + # Preserve EXIF data + if hasattr(img, 'info') and 'exif' in img.info: + raw_exif = img.info['exif'] + + if options: + options['exif'] = raw_exif + else: + options = {'exif': raw_exif} + # Rotate the img, and catch IOError when PIL fails to read EXIF try: img = Transpose().process(img)