The ANTIALIAS constant was removed in Pillow 10.0.0 (after being deprecated through many previous versions). Now you need to use PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS.
(This is the exact same algorithm that ANTIALIAS referred to - you just can no longer access it through the name ANTIALIAS.) The Lanczos filter exists since 1979 as is named as such in virtually all other picture applications/libraries (along with other interpolation filters).
Simple code example:
import PIL
import numpy as np
# Gradient image with a sharp color boundary across the diagonal
large_arr = np.fromfunction(lambda x, y, z: (x+y)//(z+1),
(256, 256, 3)).astype(np.uint8)
large_img = PIL.Image.fromarray(large_arr)
# Resize it: PIL.Image.LANCZOS also works here
small_img = large_img.resize((128, 128), PIL.Image.Resampling.LANCZOS)
print(small_img.size)
large_img.show()
small_img.show()
Answer from slothrop on Stack OverflowThe ANTIALIAS constant was removed in Pillow 10.0.0 (after being deprecated through many previous versions). Now you need to use PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS.
(This is the exact same algorithm that ANTIALIAS referred to - you just can no longer access it through the name ANTIALIAS.) The Lanczos filter exists since 1979 as is named as such in virtually all other picture applications/libraries (along with other interpolation filters).
Simple code example:
import PIL
import numpy as np
# Gradient image with a sharp color boundary across the diagonal
large_arr = np.fromfunction(lambda x, y, z: (x+y)//(z+1),
(256, 256, 3)).astype(np.uint8)
large_img = PIL.Image.fromarray(large_arr)
# Resize it: PIL.Image.LANCZOS also works here
small_img = large_img.resize((128, 128), PIL.Image.Resampling.LANCZOS)
print(small_img.size)
large_img.show()
small_img.show()
The problem is with Pillow 10.0.
Trying to uninstall Pillow might give some errors.
Just put this in cmd:
pip install Pillow==9.5.0