Help regarding Python Pillow Library

Hi Everyone
I recently tried to experiment with the Python Pillow Library.
I tried to resize and round the corners of the following image.


I got an unexpected result due to the sharp pixels in the circumference.

But when I tried the same using an image editor, there was a smooth circumference.


I tried to use FileImage.filter(ImageFilter.SMOOTH_MORE) but the quality deteriorated.

My code to edit the Image

RoundSize= 60
FileImage ="Image.png")
Size = 200
FileImage = FileImage.resize((Size,int((float(FileImage.size[1])*float((Size/float(FileImage.size[0])))))), Image.ANTIALIAS)
Round ='L', (RoundSize* 2, RoundSize* 2), 0)
Draw = ImageDraw.Draw(Round)
Draw.ellipse((0, 0, RoundSize* 2, RoundSize* 2), fill=255)
ModifiedImage ='L', FileImage.size, 255)
Width, Height = FileImage.size
ModifiedImage.paste(Round.crop((0, 0, RoundSize, RoundSize)), (0, 0))
ModifiedImage.paste(Round.crop((0, RoundSize, RoundSize, RoundSize* 2)), (0, Height - RoundSize))
ModifiedImage.paste(Round.crop((RoundSize, 0, RoundSize* 2, RoundSize)), (Width - RoundSize, 0))
ModifiedImage.paste(Round.crop((RoundSize, RoundSize, RoundSize* 2, RoundSize* 2)), (Width - RoundSize, Height - RoundSize))
FileImage.putalpha(ModifiedImage)"Python Edited.png")

Hi, @skyreach. I guess the link below would be helpful for you. If you still find any issue, reply with the updated code.
Stack Overflow

I think you’re on the right track with this (or another blurring filter). Have you tried applying the filter to your alpha mask ModifiedImage rather than the whole image?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.