import base64 import subprocess from pathlib import Path OUT = Path(__file__).resolve().parent WIDTH, HEIGHT = 2048, 768 BLUE = "#07527b" ORANGE = "#ed8208" YELLOW = "#fff2a6" def orange_icon(cx, cy, scale=1.0): return f''' ''' def text(x, y, value, size, fill=BLUE, weight=700, family="Arial, sans-serif", spacing=0): return (f'{value}') base64_image = base64.b64encode((OUT / "decorative_base_cutout.png").read_bytes()).decode("ascii") parts = [f''' '''] for x in (0, WIDTH): parts.append(orange_icon(x, 346, 1.1)) for x in (290, 1758): parts.append(orange_icon(x, 245, 1.25)) parts.append(text(x, 385, "ORANGE", 24, weight=700, spacing=1.8)) parts.append(f'') parts.extend([ text(1024, 309, "ORANGE", 65, weight=900, spacing=1), text(1024, 380, "JUICE", 58, weight=900, spacing=4), '', text(1024, 556, "FRESH & FRUITY", 17, fill=YELLOW, weight=700, spacing=2.5), text(1024, 616, "鲜橙汁", 45, fill=YELLOW, weight=600, family="PingFang SC, Microsoft YaHei, sans-serif", spacing=4), text(1024, 669, "2 L", 28, fill=YELLOW, weight=700, spacing=3), '', ]) svg_path = OUT / "orange_juice_wrap.svg" svg_path.write_text("\n".join(parts), encoding="utf-8") subprocess.run(["sips", "-s", "format", "png", str(svg_path), "--out", str(OUT / "orange_juice_wrap.png")], check=True) subprocess.run([ "ffmpeg", "-hide_banner", "-loglevel", "error", "-y", "-i", str(OUT / "orange_juice_wrap.png"), "-vf", "crop=960:768:544:0", "-frames:v", "1", str(OUT / "orange_juice_front.png"), ], check=True) print(OUT / "orange_juice_wrap.svg") print(OUT / "orange_juice_wrap.png") print(OUT / "orange_juice_front.png")