Skip to content

Commit

Permalink
New setting to disable autorotation of images, and warn about the
Browse files Browse the repository at this point in the history
incompatibility between autorotation and EXIF copy (ref #72).
  • Loading branch information
saimn committed Mar 10, 2014
1 parent befc358 commit 07f0c42
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/changelog.rst
Expand Up @@ -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
~~~~~~~~~~~~~
Expand Down
14 changes: 10 additions & 4 deletions sigal/image.py
Expand Up @@ -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:
Expand All @@ -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']:
Expand Down
3 changes: 2 additions & 1 deletion sigal/settings.py
Expand Up @@ -32,7 +32,8 @@
'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': (),
Expand Down
8 changes: 7 additions & 1 deletion sigal/templates/sigal.conf.py
Expand Up @@ -107,8 +107,14 @@
# 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 = ''
Expand Down

0 comments on commit 07f0c42

Please sign in to comment.