Skip to content

Commit 3554008

Browse files
committed
add Yixiaohan dir and 0000 solution
1 parent 68bb59d commit 3554008

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr /bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果。
6+
Pillow:Python Imaging Library
7+
PIL.ImageDraw.Draw.text(xy, text, fill=None, font=None, anchor=None)
8+
"""
9+
10+
from PIL import Image, ImageDraw, ImageFont
11+
12+
original_avatar = 'weChat_avatar.png'
13+
saved_avatar = 'new_avatar.png'
14+
windows_font = 'Arial.ttf'
15+
color = (255, 0, 0)
16+
17+
def draw_text(text, fill_color, windows_font):
18+
try:
19+
im = Image.open(original_avatar)
20+
x, y = im.size
21+
print "The size of the Image is: "
22+
print(im.format, im.size, im.mode)
23+
im.show()
24+
25+
draw = ImageDraw.Draw(im)
26+
font = ImageFont.truetype(windows_font, 35)
27+
draw.text((x-20, 7), text, fill_color, font)
28+
29+
im.save(saved_avatar)
30+
im.show()
31+
32+
except:
33+
print "Unable to load image"
34+
35+
if __name__ == "__main__":
36+
#number = str(raw_input('please input number: '))
37+
number = str(4)
38+
draw_text(number, color, windows_font)

Yixiaohan/0000/weChat_avatar.png

8.33 KB
Loading

0 commit comments

Comments
 (0)