阅读(435) (11)

Pillow ImageDraw绘制多行文字

2021-07-13 17:31:46 更新

示例:绘制多行文字

from PIL import Image, ImageDraw, ImageFont

# create an image
out = Image.new("RGB", (150, 100), (255, 255, 255))

# get a font
fnt = ImageFont.truetype("Pillow/Tests/fonts/FreeMono.ttf", 40)
# get a drawing context
d = ImageDraw.Draw(out)

# draw multiline text
d.multiline_text((10,10), "HellonWorld", font=fnt, fill=(0, 0, 0))

out.show()