Spaces:
Sleeping
Sleeping
File size: 1,491 Bytes
f5403c7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | from pathlib import Path
import json
import sys
from PIL import Image, ImageDraw
ROOT = Path(__file__).resolve().parents[1]
SRC = ROOT / "src"
if str(SRC) not in sys.path:
sys.path.insert(0, str(SRC))
from dot2dot.pipeline import DotToDotPipeline
def make_duck_like_outline(path: Path) -> Path:
image = Image.new("RGB", (1200, 1200), "white")
draw = ImageDraw.Draw(image)
draw.ellipse((250, 430, 860, 900), outline="black", width=18)
draw.ellipse((720, 260, 980, 520), outline="black", width=18)
draw.polygon([(960, 380), (1120, 330), (1110, 430)], outline="black", fill="white")
draw.line((370, 860, 320, 1030), fill="black", width=18)
draw.line((540, 860, 520, 1030), fill="black", width=18)
draw.arc((120, 510, 360, 780), start=300, end=80, fill="black", width=18)
image.save(path)
return path
def main() -> None:
output_dir = ROOT / "output" / "smoke_test"
input_dir = ROOT / "input" / "smoke_test"
output_dir.mkdir(parents=True, exist_ok=True)
input_dir.mkdir(parents=True, exist_ok=True)
source_path = make_duck_like_outline(input_dir / "duck_outline.png")
pipeline = DotToDotPipeline()
result = pipeline.build_book(
input_dir=input_dir,
output_dir=output_dir,
age_key="6-8",
title="Patinho Liga Pontos",
trim_size="8.5x11",
)
print(json.dumps({"source": str(source_path), **result}, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()
|