misc: use PIL.Image.Resampling.LANCZOS instead of PIL.Image.LANCZOS (#71899)

PIL.Image.LANCZOS is deprecated.
This commit is contained in:
Benjamin Dauvergne 2022-12-01 08:56:26 +01:00
parent 3fcbe2198c
commit 855bb179b0
2 changed files with 7 additions and 1 deletions

View File

@ -147,7 +147,12 @@ class ProfileImageField(FileField):
box[3] += box[1]
image = image.crop(box)
return image.resize([width, height], PIL.Image.LANCZOS)
try:
resampling_algorithm = PIL.Image.Resampling.LANCZOS
except AttributeError:
# can be removed when Pillow < 9.1.0 is not supported anymore
resampling_algorithm = PIL.Image.LANCZOS
return image.resize([width, height], resampling_algorithm)
class ValidatedEmailField(EmailField):

View File

@ -179,6 +179,7 @@ filterwarnings =
error:.*please use dns.resolver.resolve:DeprecationWarning:
error:.*Passing None for the middleware get_response argument is deprecated.*::
error:.*ANTIALIAS is deprecated and will be removed in Pillow 10::
error:.*LANCZOS.*Pillow 10::
junit_family=xunit2
[coverage:run]