diff --git a/WangZhou/0000/consolab.ttf b/WangZhou/0000/consolab.ttf new file mode 100644 index 00000000..55f6bd2f Binary files /dev/null and b/WangZhou/0000/consolab.ttf differ diff --git a/WangZhou/0000/insert_num_angle.py b/WangZhou/0000/insert_num_angle.py new file mode 100644 index 00000000..73242822 --- /dev/null +++ b/WangZhou/0000/insert_num_angle.py @@ -0,0 +1,20 @@ +from PIL import Image, ImageDraw, ImageFont + + +def insert_angle_num(img): + """ + Insert a num on the right-upper angle,then save the new image. + :param img:string : filename of an Image object + """ + with Image.open(img) as im: + width, height = im.size + draw_image = ImageDraw.Draw(im) + color = '#ff0000' + num_font = ImageFont.truetype('consolab.ttf', 100) + draw_image.text((width - 80, 20), '7', font=num_font, fill=color) + im.save('new_message.jpg') + + +if __name__ == "__main__": + img = 'wz0000.jpg' + insert_angle_num(img) diff --git a/WangZhou/0000/new_message.jpg b/WangZhou/0000/new_message.jpg new file mode 100644 index 00000000..6f3bb4ef Binary files /dev/null and b/WangZhou/0000/new_message.jpg differ diff --git a/WangZhou/0000/wz0000.jpg b/WangZhou/0000/wz0000.jpg new file mode 100644 index 00000000..d4a4d920 Binary files /dev/null and b/WangZhou/0000/wz0000.jpg differ diff --git a/WangZhou/0001/gen_act_key.py b/WangZhou/0001/gen_act_key.py new file mode 100644 index 00000000..45909b32 --- /dev/null +++ b/WangZhou/0001/gen_act_key.py @@ -0,0 +1,21 @@ +import uuid + + +def gen_act_key(n): + """ + 生成 n 个激活码,保存在字典。 + :param n: int + :return: dict + """ + act_code_store = {} + + for i in range(n): + code0 = str(uuid.uuid1()).split('-')[0] + code1 = '-'.join(str(uuid.uuid3(uuid.NAMESPACE_DNS, f'{i}')).split('-')[1:]) + act_code = code0 + '-' + code1 + act_code_store[f'id-{i}'] = act_code + return act_code_store + + +if __name__ == "__main__": + activity_code = gen_act_key(200)