Handle deprecation

This commit is contained in:
Simon Conseil
2022-08-02 17:15:51 +02:00
parent 3ce86e5763
commit ce40d846fe

View File

@@ -161,10 +161,16 @@ def generate_thumbnail(
img = Transpose().process(img)
original_format = img.format
try:
method = PILImage.Resampling.LANCZOS
except AttributeError:
# Deprecated since version 9.1.0
method = PILImage.ANTIALIAS
if fit:
img = ImageOps.fit(img, box, PILImage.Resampling.LANCZOS, centering=thumb_fit_centering)
img = ImageOps.fit(img, box, method, centering=thumb_fit_centering)
else:
img.thumbnail(box, PILImage.Resampling.LANCZOS)
img.thumbnail(box, method)
outformat = img.format or original_format or 'JPEG'
logger.debug('Save thumnail image: %s (%s)', outname, outformat)