From 07f0c42396127a0ed25782e3606623b73fdb8a7e Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Tue, 11 Mar 2014 00:05:34 +0100 Subject: [PATCH] New setting to disable autorotation of images, and warn about the incompatibility between autorotation and EXIF copy (ref #72). --- docs/changelog.rst | 2 ++ sigal/image.py | 14 ++++++++++---- sigal/settings.py | 3 ++- sigal/templates/sigal.conf.py | 8 +++++++- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 161fda9..ba523a9 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -20,6 +20,8 @@ Released on 2014-xx-xx. - New settings to define the sort order for albums and medias: ``albums_sort_reverse``, ``medias_sort_attr``, ``medias_sort_reverse``. +- New setting ``autorotate_images`` to disable autorotation of images, and warn + about the incompatibility between autorotation and EXIF copy. Version 0.6.0 ~~~~~~~~~~~~~ diff --git a/sigal/image.py b/sigal/image.py index a6aa2a1..56d5cbf 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -64,6 +64,11 @@ def generate_image(source, outname, settings, options=None): img = PILImage.open(source) original_format = img.format + if settings['copy_exif_data'] and settings['autorotate_images']: + logger.warning("The 'autorotate_images' and 'copy_exif_data' settings " + "are not compatible because Sigal can't save the " + "modified Orientation tag.") + # Preserve EXIF data if settings['copy_exif_data'] and _has_exif_tags(img): if options is not None: @@ -73,10 +78,11 @@ def generate_image(source, outname, settings, options=None): options['exif'] = img.info['exif'] # Rotate the img, and catch IOError when PIL fails to read EXIF - try: - img = Transpose().process(img) - except (IOError, IndexError): - pass + if settings['autorotate_images']: + try: + img = Transpose().process(img) + except (IOError, IndexError): + pass # Resize the image if settings['img_processor']: diff --git a/sigal/settings.py b/sigal/settings.py index 396b736..138a533 100644 --- a/sigal/settings.py +++ b/sigal/settings.py @@ -32,7 +32,8 @@ _DEFAULT_CONFIG = { 'adjust_options': {'color': 1.0, 'brightness': 1.0, 'contrast': 1.0, 'sharpness': 1.0}, 'albums_sort_reverse': False, - 'copy_exif_data': True, + 'autorotate_images': True, + 'copy_exif_data': False, 'copyright': '', 'destination': '_build', 'files_to_copy': (), diff --git a/sigal/templates/sigal.conf.py b/sigal/templates/sigal.conf.py index 1cd0b07..c28b5cf 100644 --- a/sigal/templates/sigal.conf.py +++ b/sigal/templates/sigal.conf.py @@ -107,8 +107,14 @@ medias_sort_reverse = False # contain all original files. # zip_gallery = False # False or 'archive.zip' +# Autorotate images +# Warning: this setting is not compatible with `copy_exif_data` (see below), +# because Sigal can't save the modified Orientation tag (currently Pillow can't +# write EXIF). +# autorotate_images = True + # If True, EXIF data from the original image is copied to the resized image -# copy_exif_data = True +# copy_exif_data = False # Specify a different locale. If set to '', the default locale is used. # locale = ''