wanlifeipeng

  博客园 :: 首页 :: 博问 :: 闪存 :: :: 联系 :: 订阅 订阅 :: 管理 ::
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)

效果:

 

posted on 2017-04-07 19:12  wanlifeipeng  阅读(1631)  评论(0编辑  收藏  举报