+1 vote
in Programming Languages by (74.2k points)

In the following code, "inImg.thumbnail(size, Image.ANTIALIAS)" gives the error: "AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS'

from PIL import Image

inImg = Image.open("example.jpg")

size = (100, 100)

inImg.thumbnail(size, Image.ANTIALIAS)

How can I fix this error?

1 Answer

+1 vote
by (56.8k points)
selected by
 
Best answer

ANTIALIAS has been removed from the latest Python module pillow, and hence, your code is giving the error. You can use "LANCZOS" instead of "ANTIALIAS" to fix the error.

Here is the modified code that will work:

from PIL import Image

inImg = Image.open("example.jpg")

size = (100, 100)

inImg.thumbnail(size, Image.LANCZOS)

 If you want to use ANTIALIAS, you need to use an older (< 10.0.0) version of "pillow".


...