Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First off, make sure you are saving your image in a format that supports transparency. <code>PNG</code> does, <code>JPG</code> does not... Below is some pretty nice code that will add transparent corners. It works like this:</p> <ol> <li>Draws a circle with radius, <code>rad</code>, using <code>draw.ellipse()</code></li> <li>Create an image for the alpha channel the same size as your image</li> <li>Chop our circle into four pieces (the rounded corners), and place them in the correct corners of the alpha image</li> <li>Put the alpha channel into your image using <code>putalpha()</code></li> <li>Save as a <code>png</code>, thus preserving transparency.</li> </ol> <p>Here is the code:</p> <pre><code>import Image, ImageDraw def add_corners(im, rad): circle = Image.new('L', (rad * 2, rad * 2), 0) draw = ImageDraw.Draw(circle) draw.ellipse((0, 0, rad * 2, rad * 2), fill=255) alpha = Image.new('L', im.size, 255) w, h = im.size alpha.paste(circle.crop((0, 0, rad, rad)), (0, 0)) alpha.paste(circle.crop((0, rad, rad, rad * 2)), (0, h - rad)) alpha.paste(circle.crop((rad, 0, rad * 2, rad)), (w - rad, 0)) alpha.paste(circle.crop((rad, rad, rad * 2, rad * 2)), (w - rad, h - rad)) im.putalpha(alpha) return im im = Image.open('tiger.jpg') im = add_corners(im, 100) im.save('tiger.png') </code></pre> <p>example curved edge tiger:</p> <p><img src="https://i.stack.imgur.com/OKoXh.png" alt="enter image description here"></p> <p>here is your image, processed with this code, giving transparent corners:</p> <p><img src="https://i.stack.imgur.com/MFQ2T.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload