Skip to content

Commit 83a017f

Browse files
committed
Add test files and require Pillow 6.0
1 parent 8f5c633 commit 83a017f

File tree

5 files changed

+10
-20
lines changed

5 files changed

+10
-20
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ install_requires =
3131
click
3232
Jinja2
3333
Markdown
34-
Pillow>=4.0.0
34+
Pillow>=6.0.0
3535
pilkit
3636
natsort
3737

sigal/image.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,14 @@
4040
from PIL import Image as PILImage
4141
from PIL import ImageFile, ImageOps, IptcImagePlugin
4242
from PIL.ExifTags import GPSTAGS, TAGS
43+
from PIL.Image import Exif
4344

4445
import pilkit.processors
4546
from pilkit.processors import Transpose
4647
from pilkit.utils import save_image
4748

48-
try:
49-
# Pillow 6.0 added a class allowing to write Exif data
50-
from PIL.Image import Exif
51-
except ImportError:
52-
Exif = None
53-
5449
from . import signals, utils
55-
from .settings import Status, get_thumb
50+
from .settings import Status
5651

5752
try:
5853
# Pillow 7.2+
@@ -79,8 +74,8 @@ def _read_image(file_path):
7974
im = PILImage.open(file_path)
8075

8176
for w in caught_warnings:
82-
logger.warning(f'PILImage reported a warning for file {file_path}\n'
83-
f'{w.category}: {w.message}')
77+
logger.info(f'PILImage reported a warning for file {file_path}\n'
78+
f'{w.category}: {w.message}')
8479
return im
8580

8681

@@ -124,15 +119,8 @@ def generate_image(source, outname, settings, options=None):
124119
pass
125120
else:
126121
if copy_exif and 'exif' in options:
127-
if Exif is not None:
128-
# reset the orientation flag
129-
options['exif'][0x0112] = 1
130-
else:
131-
logger.warning(
132-
"'autorotate_images' and 'copy_exif_data' settings "
133-
"are not compatible when using Pillow < 6.0, because "
134-
"Sigal can't save the modified Orientation tag."
135-
)
122+
# reset the orientation flag
123+
options['exif'][0x0112] = 1
136124

137125
# Resize the image
138126
if settings['img_processor']:
137 KB
Loading

tests/sample/sigal.conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
keep_orig = True
66
thumb_video_delay = 5
77
# img_format = 'jpeg'
8+
copy_exif_data = True
89

910
links = [('Example link', 'http://example.org'),
1011
('Another link', 'http://example.org')]

tests/test_extended_caching.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
def test_save_cache(settings, tmpdir):
1111
settings['destination'] = str(tmpdir)
1212
gal = Gallery(settings, ncpu=1)
13+
__import__('pdb').set_trace()
1314
extended_caching.save_cache(gal)
1415

1516
cachePath = os.path.join(settings['destination'], ".exif_cache")
@@ -21,7 +22,7 @@ def test_save_cache(settings, tmpdir):
2122

2223
assert cache["exifTest/21.jpg"] == gal.albums["exifTest"].medias[0].exif
2324
assert cache["exifTest/22.jpg"] == gal.albums["exifTest"].medias[1].exif
24-
assert cache["exifTest/noexif.png"] == gal.albums["exifTest"].medias[2].exif
25+
assert cache["exifTest/noexif.png"] is None
2526

2627

2728
def test_restore_cache(settings, tmpdir):

0 commit comments

Comments
 (0)