[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: PIL question

Fredrik Lundh

1/9/2008 1:03:00 PM

Alex K wrote:

> Would anyone know how to generate thumbnails with rounded corners
> using PIL? I'm also considering imagemagick if PIL turns out not to be
> appropriate for the task.

create a mask image with round corners (either with your favourite image
editor or using ImageDraw/aggdraw or some such).

in your program, load the mask image, and cut out the four corners using
"crop".

then, for each image, create a thumbnail as usual, and use the corner
masks on the corners of the thumbnail.

- if you want transparent corners, create an "L" image with the same
size as the thumbnail, use "paste" to add the corner masks in that
image, and then use "putalpha" to attach the alpha layer it to the
thumbnail.

- if you want solid corners, use "paste" on the thumbnail instead, using
a solid color as the source.

</F>