首页 Python通用模块视频教程 Pillow ImageFont为图片添加文字水印方法text()
pay pay

Pillow ImageFont为图片添加文字水印方法text()

日期: 五月 11, 2023, 10:49 a.m.
阅读: 125
作者: Python自学网-村长

摘要: Pillow ImageFont为图片添加文字水印方法text()

# 2.ImageFont
from PIL import ImageFont, ImageDraw

# 打开图片,返回 Image对象
im = Image.open("2023.png")
# 创建画布对象
draw = ImageDraw.Draw(im)
# 加载计算机本地字体文件
# font = ImageFont.truetype('angsab.ttf', size=36)
font = ImageFont.truetype('站酷庆科黄油体.ttf', size=50)
# 在原图像上添加文本
draw.text(xy=(80, 50), text='Python自学网', fill=(255, 0, 0), font=font)
im.show()

 

原创视频,版权所有,未经允许,切勿转载,违者必究!
回顶部