To improve image quality of made circular thumbnails

Mark K :

How do I generate circular thumbnails with PIL? shows a way how to make circular thumbnails.

Following the sample and I am using a picture here, and here's what's generated.

enter image description here

The generated picture quality doesn't look very good, I want to improve it, so change the last line a bit:

from PIL import Image, ImageOps

mask = Image.open('mask.png').convert('L')
im = Image.open('image.png')

output = ImageOps.fit(im, mask.size, centering=(0.5, 0.5))
output.putalpha(mask)

output.save('output.png', dpi=(800,800))

But seems the picture quality is not improved.

What's the way to improve the picture quality after circled? Thank you.

Ture Pålsson :

Try using a different downsampling filter, by adding, for example, method=Image.LANCZOS to the .fit call.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=13894&siteId=1