Skip to content

Commit 30898db

Browse files
committed
1 parent ea9f186 commit 30898db

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

LiamHuang/0000.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# coding: utf-8
2+
"""
3+
0000:
4+
将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。
5+
类似于图中效果 http://i.imgur.com/sg2dkuY.png?1
6+
"""
7+
8+
from PIL import Image, ImageDraw, ImageFont
9+
10+
sourceFileName = "source.png"
11+
avatar = Image.open(sourceFileName)
12+
drawAvatar = ImageDraw.Draw(avatar)
13+
14+
xSize, ySize = avatar.size
15+
fontSize = min(xSize, ySize) // 11
16+
17+
myFont = ImageFont.truetype("/Library/Fonts/OsakaMono.ttf", fontSize)
18+
19+
drawAvatar.text([0.9 * xSize, 0.1 * ySize - fontSize],\
20+
"3", fill = (255, 0, 0), font = myFont)
21+
del drawAvatar
22+
23+
avatar.show()

LiamHuang/source.png

164 KB
Loading

0 commit comments

Comments
 (0)