diff --git a/Ma233/0000/SLUG.png b/Ma233/0000/SLUG.png new file mode 100644 index 00000000..1896ce49 Binary files /dev/null and b/Ma233/0000/SLUG.png differ diff --git a/Ma233/0000/add_num.py b/Ma233/0000/add_num.py new file mode 100644 index 00000000..64efe186 --- /dev/null +++ b/Ma233/0000/add_num.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# coding=utf-8 +from PIL import Image, ImageDraw, ImageFont + + +def add_num(pic_path, num, size=None, place=None): + pic = Image.open(pic_path) + + width, height = pic.size + font_size = size if size else int(height / 5) + place = place if place else (width - font_size, 0) + + drawer = ImageDraw.Draw(pic) + number_font = ImageFont.truetype('microsoft_yahei.TTF', font_size) + drawer.text(place, str(num), fill=(255, 0, 0), font=number_font) + + pic.save('with_num.png') + + +if __name__ == '__main__': + add_num('SLUG.png', 4) diff --git a/Ma233/0000/microsoft_yahei.TTF b/Ma233/0000/microsoft_yahei.TTF new file mode 100644 index 00000000..aa23ae1f Binary files /dev/null and b/Ma233/0000/microsoft_yahei.TTF differ