diff --git a/全员营销奖励.py b/全员营销奖励.py new file mode 100644 index 0000000..25652f5 --- /dev/null +++ b/全员营销奖励.py @@ -0,0 +1,30 @@ +from PIL import Image, ImageDraw, ImageFont + + +def add_text(image, font_path, save_name): + # 打开图片 + image = Image.open(r"D:\下载\员工奖励bg.png") + + # 创建一个可编辑的图片副本 + draw = ImageDraw.Draw(image) + + # 设置要添加的文本 + text = "手机银行" + + # 选择字体和字号 + font_path = r"C:\Users\Cori\OneDrive\Documents\WeChat Files\fumeng0108\FileStorage\File\2020-05\思源黑体(7款)\思源黑体(7款)\SourceHanSansCN-Bold.otf" + font = ImageFont.truetype(font_path, 36) + + # 获取文本大小 + text_width, text_height = draw.textsize(text, font) + + # 计算文本的位置使其居中 + image_width, image_height = image.size + text_x = (image_width - text_width) / 2 + text_y = 19 + + # 在图片上添加文本 + draw.text((text_x, text_y), text, font=font, fill="#AA1017") + + # 保存修改后的图片 + image.save(r"D:\下载\员工营销\1bg.png") \ No newline at end of file