PIL文字与图片合成

PIL文字与图片合成

#--coding:utf-8--
from PIL import Image, ImageDraw, ImageFont, ImageFilter
import os
font = ImageFont.truetype("./经典宋体简.TTF", 61)
font.getsize(“AB”)
scene_text = Image.new(‘RGBA’, (165, 165))
draw = ImageDraw.Draw(scene_text)
draw.text((30,30),“AB”,fill=(23,0,0),font=font)
bk= Image.open("./4.jpg")
img = bk.crop((0,0,300,300))
img.paste(scene_text, mask=scene_text)
img.save(“1.jpg”)

猜你喜欢

转载自blog.csdn.net/zz_hh_uu_/article/details/82974516