35 lines
1.6 KiB
Python
35 lines
1.6 KiB
Python
from pathlib import Path
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
OUT = Path(__file__).with_name("dingtalk-vision-acceptance.png")
|
|
FONT_PATH = "/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc"
|
|
|
|
image = Image.new("RGB", (1280, 720), "#F7FAFC")
|
|
draw = ImageDraw.Draw(image)
|
|
font_title = ImageFont.truetype(FONT_PATH, 46)
|
|
font_code = ImageFont.truetype(FONT_PATH, 58)
|
|
font_label = ImageFont.truetype(FONT_PATH, 34)
|
|
font_question = ImageFont.truetype(FONT_PATH, 38)
|
|
|
|
# Header and unique OCR target.
|
|
draw.rounded_rectangle((50, 40, 1230, 190), radius=24, fill="#E6F4FF", outline="#1677FF", width=4)
|
|
draw.text((85, 65), "WeKnora 钉钉多模态验收图", font=font_title, fill="#102A43")
|
|
draw.text((85, 120), "唯一验收码:WK-VISION-7264", font=font_code, fill="#C53030")
|
|
|
|
# Three visually distinct objects.
|
|
draw.ellipse((120, 280, 340, 500), fill="#1677FF", outline="#0B4F9C", width=8)
|
|
draw.text((160, 520), "蓝色圆形", font=font_label, fill="#0B4F9C")
|
|
|
|
draw.polygon([(520, 500), (650, 275), (780, 500)], fill="#FFD43B", outline="#9C7600", width=8)
|
|
draw.text((548, 520), "黄色三角形", font=font_label, fill="#725500")
|
|
|
|
draw.rounded_rectangle((940, 295, 1140, 495), radius=12, fill="#2FB344", outline="#176B2A", width=8)
|
|
draw.text((958, 520), "绿色方形", font=font_label, fill="#176B2A")
|
|
|
|
question = "问题:蓝色圆形右侧紧邻的图形是什么颜色和形状?"
|
|
draw.rounded_rectangle((80, 610, 1200, 690), radius=18, fill="#FFF4E6", outline="#E67700", width=3)
|
|
draw.text((110, 625), question, font=font_question, fill="#7C3E00")
|
|
|
|
image.save(OUT, format="PNG", optimize=True)
|
|
print(OUT)
|