Python IPL

# Python 图片添加文字水印

from PIL import Image, ImageFont, ImageDraw

img = Image.open("12.png")
fnt = ImageFont.truetype("PingFang-SC-Regular.ttf", 60)
draw = ImageDraw.Draw(img)
draw.text((10, 25), u"测试Hello ~!~~~!~!@~~!", font=fnt, fill="yellow")

# img.show()
img.save("1234.png", "png")


# Python 图片同时添加文字 和 图片 水印

from PIL import Image, ImageFont, ImageDraw

img = Image.open("12.png")
img_mark = Image.open("water.png")
fnt = ImageFont.truetype("PingFang-SC-Regular.ttf", 60)
draw = ImageDraw.Draw(img)
draw.text((10, 25), u"测试Hello ~!~~~!~!@~~!", font=fnt, fill="yellow")
layer=Image.new('RGBA', img.size, (0,0,0,0))
layer.paste(img_mark, (img.size[0]-150,img.size[1]-60))
out=Image.composite(layer,img,layer)

# img.show()
out.save("1234.png", "png")

 

posted @ 2018-10-23 13:55  阿波罗一号  阅读(402)  评论(0编辑  收藏  举报