python小練習①
阿新 • • 發佈:2017-07-01
spa 微信 logs draw .com odin height hub git
題目內容:
將你的 QQ 頭像(或者微博頭像)右上角加上紅色的數字,類似於微信未讀信息數量那種提示效果。 類似於圖中效果
#!usr/bin/env python #_*_coding:utf-8_*_ from PIL import Image, ImageDraw, ImageFont def add_num(image): draw = ImageDraw.Draw(img) myfont = ImageFont.truetype(‘C:\Users\Lenovo\Deskto\687474703a2f2f692e696d6775722e636f6d2f736732646b75592e706e673f31.png‘, size=40) fillcolor = "#ff0000" width, height = img.size draw.text((width-40, 0), ‘99‘, font=myfont, fill=fillcolor) img.save(‘result.jpg‘,‘jpeg‘) return 0
python小練習①