Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Raynxxx/0000/ex00.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
__author__ = 'rayn'

#problem 0000
#Add a unread number on the face icon

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw

class UnreadTagFace:
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("Arial.ttf", 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('face' + tag_str + '.jpg')
return True


solver = UnreadTagFace()
solver.open('face.jpg')
solver.draw(4)








Binary file added Raynxxx/0000/face.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Raynxxx/0000/face4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.