forked from Show-Me-the-Code/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0000.py
More file actions
92 lines (41 loc) · 1.88 KB
/
0000.py
File metadata and controls
92 lines (41 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
'''from PIL import Image,ImageFont,ImageDraw
class UnreadTag:
def __init__(self):
self.img = None
self.num = None
def open(self,image_path):
self.img = Image.open(image_path)
return True
def draw(self,tag_num = 1):
tag_size = max(self.img.size[0],self.img.size[1]) / 5
tag_str = str(tag_num) if tag_num < 100 else '99+'
font = ImageFont.truetype("simsun.ttc",tag_size)
px = self.img.size[0]-font.getsize(tag_str)[0]
draw_pen = ImageDraw.Draw(self.img)
draw_pen.text((px,0), tag_str, (255,0,0), font)
self.img.save('D:/python workSpace/showmethecode/0000/face' + tag_str + '.jpg')
return True
solver = UnreadTag()
solver.open('D:/python workSpace/showmethecode/0000/face.jpg')
solver.draw(25)
'''
from PIL import Image,ImageDraw,ImageFont
class UnreadInformation:
def __init__(self):
self.image = None
self.unread = None
def open(self,image_path):
self.image = Image.open(image_path)
return True
def draw(self,unread = 1):
unread_str = str(unread) if unread < 100 else '99+'
unread_size = max(self.image.size[0],self.image.size[1]) / 4
font = ImageFont.truetype("simsun.ttc",unread_size)
location_x = (self.image.size[0] - font.getsize(unread_str)[0])
draw = ImageDraw.Draw(self.image)
draw.text((location_x,0),unread_str,(255,0,0),font)
self.image.save('D:/python workSpace/showmethecode/0000/face' + unread_str + '.jpg')
return True
test = UnreadInformation()
test.open('D:/python workSpace/showmethecode/0000/face.jpg')
test.draw(25)