bkimg="a.jpg"
fnm="res.gif"
ffont="/System/Library/Fonts/STHeiti Medium.ttc" #.ttf
images=[]
com="comm 文本-_-"
com_c=(0,0,0)
arr_txt=["文本1", com, com, "文本1",com, com,
"文本1",com, com, "文本1",com, com]
arr_color=[(0,128,128), ( 128,0,128 ), (0,0,255),(255,0,255)]
pos=(120,170)
for i, txt in enumerate(arr_txt):
if i%3==0:
color=arr_color[i//3]
else: color = com_c
#pilimg = Image.fromarray(img)
pilimg = Image.open(bkimg)
draw = ImageDraw.Draw(pilimg)
# 参数1:字体文件路径,参数2:字体大小
font = ImageFont.truetype(ffont, 56, encoding="utf-8")
draw.text(pos, txt, color, font=font)
images.append(pilimg)
images[0].save(fnm,save_all=True,loop=0,append_images=images[1:],duration=550)
[小脚本] python 制作文字GIF
最新推荐文章于 2022-08-03 14:29:20 发布