Monday, 15 September 2014

Any way to make nice antialiased round corners for images in python? -


Is there any way to create good rounded corners with python? Presently PIL and GD2 are used in my project. Both have a arc () method, which allows you to attract a square-circle, but there is no square-cycle antialiase, so the image looks crispy.

Is there a well-organized way to make antihilas / smooth round corners?

What I usually do is to use an image, for example, a mask, Such as:

border tag

  border = Image.open ('border.png') source = boundary. Convert ('RGB') img.paste (source, mask = border)  

The shape of the mask can be changed to fit the dimensions you want. Just make sure to use the image. ANTIALIAS method

For more information, I wrote some time ago (shameless plug)

If you want more control over the size and radius then you have to use arc or peal But I have made this spherical rectangle with PIL which looks quite smooth for me:

Here I used to attract it! / P>

You may want to check the fret: This Python And is written in the PIL and can apply to the corners of the goal more.

alt text

here The code used to implement round corners is a link:

It also looks quite easy for me.


No comments:

Post a Comment