Skip to content

Commit 5184c77

Browse files
committed
Complete 0000
1 parent bb77cb4 commit 5184c77

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

DIYgod/0000/Futura.ttf

76.9 KB
Binary file not shown.

DIYgod/0000/add_num.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -*- coding:utf-8 -*-
2+
# 第 0000 题:将你的 QQ 头像(或者微博头像)右上角加上红色的数字,类似于微信未读信息数量那种提示效果
3+
4+
from PIL import Image, ImageDraw, ImageFont
5+
6+
def add_num(picPath, num):
7+
img = Image.open(picPath)
8+
x, y = img.size
9+
myfont = ImageFont.truetype('Futura.ttf', x / 3)
10+
ImageDraw.Draw(img).text((2* x / 3, 0), str(num), font = myfont, fill = 'red')
11+
img.save('pic_with_num.jpg')
12+
13+
if __name__ == '__main__':
14+
add_num('pic.jpg', 9)

DIYgod/0000/pic.jpg

68 KB
Loading

DIYgod/0000/pic_with_num.jpg

17.8 KB
Loading

0 commit comments

Comments
 (0)