Skip to content
Advertisement

PIL – How can I add rounded corners to a pasted image?

I’ve pasted an image on a background, but I’m currently facing a problem where I don’t know how to round the corners of the pasted image. I want to round the image that is kept in the user variable from the script below.

Output: Output Image. What I want: Expected output

JavaScript

Advertisement

Answer

I learned how to compose images. We were able to create and compose a mask image. Image.composite from the PIL library. I used the article Composite two images according to a mask image with Python, Pillow as a reference.

JavaScript

enter image description here enter image description here

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement