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

How do I fix this in python?

Add Comment
2 Answers
You're probably trying to access the `ANTIALIAS` attribute in the wrong way. This attribute is not directly under `PIL.Image`. Instead, it belongs to `PIL.Image`'s `Image` class, and you need to import that first. Here's how you should do it: ```python from PIL import Image # some code here img = Image.open('some_image.jpg') resized_img = img.resize((width, height), Image.ANTIALIAS) ``` So instead of calling `PIL.Image.ANTIALIAS`, call `Image.ANTIALIAS`. Please note that `ANTIALIAS` is a resampling filter. It is used when you resize an image. It can give high-quality downsampling but might be a bit slow.
Answered on August 7, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.