You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
581 B

11 months ago
from PIL import Image, ImageDraw, ImageFont
def WriteWenZi(image_path):
# 打开图片
image = Image.open(image_path)
# 创建字体对象
11 months ago
font = ImageFont.truetype('simkai.ttf', size=100)
11 months ago
# 创建绘图对象
draw = ImageDraw.Draw(image)
# 设置文本内容和坐标
11 months ago
text = 'AI生成'
x = image.width - 300
y = image.height - 130
11 months ago
# 绘制文本
draw.text((x, y), text, font=font, fill='white')
# 保存修改后的图片
image.save(image_path)
image.close()
11 months ago
#WriteWenZi("d:\\9.png")