AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' - PYTHON

AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' - PYTHON, someone asked me to explain?

I got this following error while running the python program."AttributeError: module 'PIL.Image' has no attribute 'ANTIALIAS' in PYTHON".

AttributeError module 'PIL.Image' has no attribute 'ANTIALIAS'

The below python program is to download image from URL and save it to the pdf file.


import requests
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
from PIL import Image
from io import BytesIO

image_url = ''

response = requests.get(image_url)

if response.status_code == 200:
    img =

    pdf_file = "output.pdf"
    c = canvas.Canvas(pdf_file, pagesize=letter)

    max_width = 500 
    width_percent = max_width / float(img.size[0])
    height = int(float(img.size[1]) * float(width_percent))

    img = img.resize((max_width, height), Image.Resampling.LANCZOS)
    temp_img_path = 'temp_image.png'
    c.drawImage(temp_img_path, 50, 700 - height)
    print(f"PDF generated with the image: {pdf_file}")
    print("Failed to fetch the image.")


ANTIALIAS is worked in old versions. If you are using Pillow 10.0.0 and above  You need to use PIL.Image.LANCZOS or PIL.Image.Resampling.LANCZOS.

  img = img.resize((max_width, height), Image.Resampling.LANCZOS)


Post your comments / questions