forked from Show-Me-the-Code/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.