app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from PIL import Image, ImageDraw # Load image image = Image.open("profile.jpg").convert("RGBA") width, height = image.size # Create circular mask mask = Image.new('L', (width, height), 0) draw = ImageDraw.Draw(mask) draw.ellipse((0, 0, width, height), fill=255) # Apply mask result = Image.new("RGBA", (width, height)) result.paste(image, (0, 0), mask=mask) result.save("circle_cropped.png") |