Image.ANTIALIAS → Image.Resampling.LANCZOS (#5692)

This commit is contained in:
Kaushal Sharma 2022-10-25 02:45:46 -07:00 committed by GitHub
parent b33244e2f0
commit f4e2a10ed6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -160,7 +160,14 @@ class ImagesPipeline(FilesPipeline):
if size:
image = image.copy()
image.thumbnail(size, self._Image.ANTIALIAS)
try:
# Image.Resampling.LANCZOS was added in Pillow 9.1.0
# remove this try except block,
# when updating the minimum requirements for Pillow.
resampling_filter = self._Image.Resampling.LANCZOS
except AttributeError:
resampling_filter = self._Image.ANTIALIAS
image.thumbnail(size, resampling_filter)
buf = BytesIO()
image.save(buf, 'JPEG')