AttributeError: module ‘PIL.Image’ has no attribute ‘ANTIALIAS’

ANTIALIAS 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.)

Reference: Pillow 10.0.0 release notes (with table of removed constants)


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()

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş