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)