from PIL import Image,ImageFont,ImageDraw def add_num(in_file,num,out_file=‘result.jpg‘): im = Image.open(in_file) font = ImageFont.truetype(‘C:/Windows/fonts/Arial.ttf‘,50) fill_color = ‘#ff0000‘ #fill_color = ‘red‘ draw = ImageDraw.ImageDraw(im) width,height = im.size draw.text((width-80,0),str(num),fill=fill_color,font=font) im.save(out_file) add_num(‘qq.jpg‘,100)
效果:
将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果
原文:http://www.cnblogs.com/hupeng1234/p/6679644.html