Python upper right corner to add a digital picture workbooks 0-

Using python2.7
use the PIL library.

#coding=utf-8
import Image,ImageFont,ImageDraw

def imageAdd(img):
    #字体大小设置
    fontSize = 40

    font = ImageFont.truetype('Arial.ttf',fontSize)

    imageDraw = ImageDraw.Draw(img)
    #获得图像尺寸
    w, h = img.size
    #输出文字
    imageDraw.text((w - fontSize, 0), str(4), font=font, fill='red')
    #存放路径
    img.save('changeQQ.jpg')

if __name__ == '__main__':
    img = Image.open('QQ.jpg')
    imageAdd(img)

Guess you like

Origin blog.csdn.net/RebelHero/article/details/78539388