from PIL import Image
def deal():
infile = './1.JPG'
outfile = './output.jpg'
im = Image.open(infile)
(x, y) = im.size # read image size
x_s = 350 # define standard width
y_s = round(y * x_s / x) # calc height based on standard width
out = im.resize((x_s, y_s), Image.ANTIALIAS) # resize image with high-quality
out.save(outfile)
deal()
python 使用pillow库裁剪图片
最新推荐文章于 2025-05-13 12:23:59 发布