Skip to content

Commit 511b973

Browse files
committed
implement solution 0001 by PIL
1 parent ea9f186 commit 511b973

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

kentsay/0001/add_num2img.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import sys
2+
from PIL import Image
3+
from PIL import ImageDraw
4+
from PIL import ImageFont
5+
6+
def add_number2img(image, number):
7+
font = ImageFont.truetype("/Library/Fonts/Chalkduster.ttf", 28)
8+
draw = ImageDraw.Draw(image)
9+
draw.text((200,0), str(number),(255, 255, 255), font=font)
10+
draw = ImageDraw.Draw(image)
11+
image.save("mask_with_num.png")
12+
image.show()
13+
14+
15+
origin = Image.open("mask.png")
16+
add_number2img(origin, sys.argv[1])

kentsay/0001/mask.png

42.9 KB
Loading

kentsay/0001/mask_with_num.png

44.1 KB
Loading

0 commit comments

Comments
 (0)