发布时间:2019-08-27 08:06:36编辑:auto阅读(1969)
一、添加文字水印
from PIL import Image, ImageDraw,ImageFont im = Image.open("d:/pic/lena.jpg").convert('RGBA') txt=Image.new('RGBA', im.size, (0,0,0,0)) fnt=ImageFont.truetype("c:/Windows/fonts/Tahoma.ttf", 20) d=ImageDraw.Draw(txt) d.text((txt.size[0]-80,txt.size[1]-30), "cnBlogs",font=fnt, fill=(255,255,255,255)) out=Image.alpha_composite(im, txt) out.show()
二、添加小图片水印
from PIL import Image im = Image.open("d:/pic/lena.jpg") mark=Image.open("d:/logo_small.gif") layer=Image.new('RGBA', im.size, (0,0,0,0)) layer.paste(mark, (im.size[0]-150,im.size[1]-60)) out=Image.composite(layer,im,layer) out.show()
上一篇: 如何用Python写一个每天的定时程序
下一篇: Python Scapy(2.3.1)文
47882
46450
37336
34773
29348
26011
24961
19979
19582
18076
5821°
6449°
5962°
5988°
7096°
5937°
5981°
6472°
6437°
7818°