Browse Source

Add test files and require Pillow 6.0

exif-rotate
Simon Conseil 5 years ago committed by Simon Conseil
parent
commit
aa0a206246
  1. 2
      setup.cfg
  2. 20
      sigal/image.py
  3. BIN
      tests/sample/pictures/exifTest/lamas.jpg
  4. 1
      tests/sample/sigal.conf.py
  5. 2
      tests/test_extended_caching.py

2
setup.cfg

@ -32,7 +32,7 @@ install_requires =
click
Jinja2
Markdown
Pillow>=4.0.0
Pillow>=6.0.0
pilkit
natsort

20
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']:

BIN
tests/sample/pictures/exifTest/lamas.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

1
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"),

2
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):

Loading…
Cancel
Save