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.
Merge pull request Show-Me-the-Code#92 from kentsay/master
Creating solution for show-me-the-code in Python
- Loading branch information
Showing
3 changed files
with
21 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,21 @@ | ||
""" | ||
Question: | ||
第 0000 题:将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。 | ||
""" | ||
|
||
import sys | ||
from PIL import Image | ||
from PIL import ImageDraw | ||
from PIL import ImageFont | ||
|
||
def add_number2img(image, number): | ||
font = ImageFont.truetype("/Library/Fonts/Chalkduster.ttf", 28) | ||
draw = ImageDraw.Draw(image) | ||
draw.text((200,0), str(number),(255, 255, 255), font=font) | ||
draw = ImageDraw.Draw(image) | ||
image.save("mask_with_num.png") | ||
image.show() | ||
|
||
|
||
origin = Image.open("mask.png") | ||
add_number2img(origin, sys.argv[1]) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.