Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2312f5a

Browse files
committed
Fix Pillow compatibility in example
1 parent de98877 commit 2312f5a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tutorials/introductory/images.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,12 @@
245245
from PIL import Image
246246

247247
img = Image.open('../../doc/_static/stinkbug.png')
248-
img.thumbnail((64, 64), Image.Resampling.LANCZOS) # resizes image in-place
248+
# Deal with different versions of Pillow
249+
if Image.hasattr('Resampling'):
250+
resamplingstrategy = Image.Resampling.LANCZOS
251+
else:
252+
resamplingstrategy = Image.LANCZOS
253+
img.thumbnail((64, 64), resamplingstrategy) # resizes image in-place
249254
imgplot = plt.imshow(img)
250255

251256
###############################################################################

0 commit comments

Comments
 (0)