Skip to content

Commit

Permalink
LiamHuang: 0000
Browse files Browse the repository at this point in the history
  • Loading branch information
Liam0205 committed May 5, 2015
1 parent ea9f186 commit 30898db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions LiamHuang/0000.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# coding: utf-8
"""
0000:
将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。
类似于图中效果 http://i.imgur.com/sg2dkuY.png?1
"""

from PIL import Image, ImageDraw, ImageFont

sourceFileName = "source.png"
avatar = Image.open(sourceFileName)
drawAvatar = ImageDraw.Draw(avatar)

xSize, ySize = avatar.size
fontSize = min(xSize, ySize) // 11

myFont = ImageFont.truetype("/Library/Fonts/OsakaMono.ttf", fontSize)

drawAvatar.text([0.9 * xSize, 0.1 * ySize - fontSize],\
"3", fill = (255, 0, 0), font = myFont)
del drawAvatar

avatar.show()
Binary file added LiamHuang/source.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 30898db

Please sign in to comment.