Python PIL thumbnail with Image.ANTIALIAS. How to maintain quality

I am trying to resize images while maintaining aspect ratio. For this, I use the PIL thumbnail method. I am using the Image.ANTIALIAS filter.

Here you can check your code:

        image = Image.open(design.design.path)
        format = image.format
        image = ImageOps.mirror(image)
        new_size = (241, 241)
        image.thumbnail(new_size, Image.ANTIALIAS)
        image.save(response, format)

This code works fine, but the quality is lost after the sketch. I see this by enlarging the image on the saved image. I see pixels in the corners of the image, while I'm not in the original image. This is even better when I print a resized image.

You can see sample images here: http://imgur.com/a/ifZoU

Please tell me if you need anything else.

+4
source share
2 answers

Image.save :

img.save(fpath, 'image/png', quality=100, optimize=True) 
+1
0

Source: https://habr.com/ru/post/1615560/


All Articles