python PIL 操作图片
第 0000 题:将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。 类似于图中效果https://camo.githubusercontent.com/d518d3929e4054ce2f9183b23e52908da7e5632d/687474703a2f2f692e696d6775722e636f6d2f736732646b75592e706e673f31https://github.com/Yixiaohan/show-me-the-code首先要安装PIL 库,参考http://liam0205.me/2015/04/22/pil-tutorial-basic-usage/
1
sudo pip install Pillow
然后python 如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from PIL import Image, ImageDraw
import sys
def DrawNotify(pic,text):
image = Image.open(pic)
imgdraw = ImageDraw.Draw(image)
#should be size ,not size()
width,height = image.size
#notice that --> w
# |
# V
# h
#should []
imgdraw.text(,text,255)
del imgdraw
#image.show()
image.save(pic)
if __name__ == '__main__':
#accept first and second arguments
DrawNotify(sys.argv,sys.argv)
页:
[1]