[Python] Pillow creating errors when resizing image

Discussão em 'Python' iniciado por Stack, Novembro 28, 2024.

  1. Stack

    Stack Membro Participativo

    # Downloads image
    def downloadImage(imageUrl, savePath):
    # Send a GET request to the URL
    response = requests.get(imageUrl)

    # Check if the request was successful
    if response.status_code == 200:
    # Open the image using PIL
    img = Image.open(BytesIO(response.content))

    # Resize the image to 512x512
    img = img.resize((512, 512), Image.BICUBIC)

    # Save the resized image
    img.save(savePath)


    I wrote this code to download an image from a URL, and then resize the image to 512x512 with Pillow. For some reason, when the image gets saved, there are strange artifacts. Below I have included two images. On the left is the original image resized in Photoshop, on the right is the image resized with Pillow. Especially around the curves, such as around the eyes, you can see strange almost bump like artifacts. Does anyone know why this is happening?

    [​IMG]

    Continue reading...

Compartilhe esta Página