Python3 图片打水印
2018-07-20 来源:open-open
from PIL import Image, ImageDraw, ImageFont import os def water_work(img): x, y = img.size textx = int(x*1.5) texty = int(y*1.5) blank = Image.new('RGB', (textx, texty), 'white') draw = ImageDraw.Draw(blank) font = ImageFont.truetype('simsun.ttc', size=50) text = '王小涛_同學' draw.ink = 100 draw.text(((textx-x/2)/2, (texty)/2), text, font=font) One_blank = blank.rotate(30) box = (730, 610, 1000, 800) textImage = One_blank.crop(box)<img src="http://img.blog.csdn.net/20150208171613764" alt="" /> pastebox = (int(x/2 + 80), int(y/2)) blank2 = Image.new('RGB', (x, y), 'white') blank2.paste(textImage, pastebox) waterImage = Image.blend(img, blank2, 0.2) #图片合并<img src="http://img.blog.csdn.net/20150208171708598" alt="" /> waterImage.save(image, quality=100) for img in os.listdir('C:/Users/hengli/Pictures/lovewallpaper'): if img.endswith('.jpg'): image = os.path.join('C:/Users/hengli/Pictures/lovewallpaper/', img) img = Image.open(image) water_work(img)
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点!
本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。
最新资讯
热门推荐