There is a code that, in principle, works:
from PIL import Image, ImageOps, ImageDraw im = Image.open('image.png') size = (200, 200) # размер итогового портрета # маска mask = Image.new('L', size, 0) draw = ImageDraw.Draw(mask) draw.ellipse((0, 0) + size, fill=255) im = im.resize(size) output = ImageOps.fit(im, mask.size, centering=(0.5, 0.5)) output.putalpha(mask) output.thumbnail(size, Image.ANTIALIAS) output.save('image_output.png') As you can see, a round image is obtained, but the proportions are distorted. How to get a round portrait based on the original image, but with normal proportions?


im.cropinstead ofim.resize? - Surfin Bird