from PIL importImage,ImageDraw,ImageFont
FileName= 'E:\savepicture\yuantu.jpg'OutName= 'E:\savepicture\shuiyin.jpg'BlogName= '小旋子的代码自习室'BlogSite= 'http://www.cnblogs.com/pheobe/'
defAdd_shuiyin(FileName,OutName):
with Image.open(FileName).convert('RGBA') as im:
shuiyin=Image.new(im.mode,im.size)
d=ImageDraw.Draw(shuiyin)
Font1=ImageFont.truetype( 'simfang.ttf',size=30)
Font2=ImageFont.truetype( 'simfang.ttf',size=20)
d.text((100,300),BlogName,fill=(0,0,0),font=Font1)
d.text((90,330),BlogSite,fill=(0,0,0),font=Font2)
out=Image.alpha_composite(im,shuiyin)
out.save(OutName)
out.show()
Add_shuiyin(FileName,OutName)