diff --git a/setup.cfg b/setup.cfg index d9eccd8..355d2c9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,7 +32,7 @@ install_requires = click Jinja2 Markdown - Pillow>=4.0.0 + Pillow>=6.0.0 pilkit natsort diff --git a/sigal/image.py b/sigal/image.py index b7009e7..0068c30 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -41,15 +41,10 @@ import pilkit.processors from PIL import Image as PILImage from PIL import ImageFile, ImageOps, IptcImagePlugin from PIL.ExifTags import GPSTAGS, TAGS +from PIL.Image import Exif from pilkit.processors import Transpose from pilkit.utils import save_image -try: - # Pillow 6.0 added a class allowing to write Exif data - from PIL.Image import Exif -except ImportError: - Exif = None - from . import signals, utils from .settings import Status @@ -78,7 +73,7 @@ def _read_image(file_path): im = PILImage.open(file_path) for w in caught_warnings: - logger.warning( + logger.info( f'PILImage reported a warning for file {file_path}\n' f'{w.category}: {w.message}' ) @@ -125,15 +120,8 @@ def generate_image(source, outname, settings, options=None): pass else: if copy_exif and 'exif' in options: - if Exif is not None: - # reset the orientation flag - options['exif'][0x0112] = 1 - else: - logger.warning( - "'autorotate_images' and 'copy_exif_data' settings " - "are not compatible when using Pillow < 6.0, because " - "Sigal can't save the modified Orientation tag." - ) + # reset the orientation flag + options['exif'][0x0112] = 1 # Resize the image if settings['img_processor']: diff --git a/tests/sample/pictures/exifTest/lamas.jpg b/tests/sample/pictures/exifTest/lamas.jpg new file mode 100644 index 0000000..a5384dc Binary files /dev/null and b/tests/sample/pictures/exifTest/lamas.jpg differ diff --git a/tests/sample/sigal.conf.py b/tests/sample/sigal.conf.py index c2dd3a3..1f79df5 100644 --- a/tests/sample/sigal.conf.py +++ b/tests/sample/sigal.conf.py @@ -5,6 +5,7 @@ thumb_suffix = ".tn" keep_orig = True thumb_video_delay = 5 # img_format = 'jpeg' +copy_exif_data = True links = [ ("Example link", "http://example.org"), diff --git a/tests/test_extended_caching.py b/tests/test_extended_caching.py index 169530b..b64c53b 100644 --- a/tests/test_extended_caching.py +++ b/tests/test_extended_caching.py @@ -21,7 +21,7 @@ def test_save_cache(settings, tmpdir): assert cache["exifTest/21.jpg"] == gal.albums["exifTest"].medias[0].exif assert cache["exifTest/22.jpg"] == gal.albums["exifTest"].medias[1].exif - assert cache["exifTest/noexif.png"] == gal.albums["exifTest"].medias[2].exif + assert cache["exifTest/noexif.png"] is None def test_restore_cache(settings, tmpdir):