Files
Sanctification/artifacts/cards/BP-015-isaiah/review/make-art-evidence.py

69 lines
2.7 KiB
Python

#!/usr/bin/env python3
"""Create non-production illustration review evidence for BP-015 candidates."""
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
ROOT = Path(__file__).resolve().parents[1]
REPO = next(p for p in ROOT.parents if (p / "docs/card-art-brief.md").is_file())
SOURCE = ROOT / "source"
FONT = ImageFont.truetype(str(REPO / "fonts/P052-Bold.otf"), 24)
def save_common(candidate_id: str) -> None:
out = ROOT / "review" / candidate_id
out.mkdir(parents=True, exist_ok=True)
image = Image.open(SOURCE / f"art-native-{candidate_id}.png").convert("RGBA")
for width in (1000, 500, 250):
image.resize((width, width * 7 // 5), Image.Resampling.LANCZOS).save(
out / f"art-{width}.png"
)
master = image.resize((2000, 2800), Image.Resampling.LANCZOS)
overlay = Image.open(
REPO / "artifacts/layers/rare/v3/exports/overlay-normal-2000.png"
).convert("RGBA")
Image.alpha_composite(master, overlay).resize(
(1000, 1400), Image.Resampling.LANCZOS
).save(out / "layout-guide-normal.png")
save_common("candidate-01")
save_common("candidate-02")
save_common("candidate-03")
candidate = Image.open(SOURCE / "art-native-candidate-03.png").convert("RGBA")
out = ROOT / "review/candidate-03"
crops = {
"figure-100.png": (145, 245, 915, 1484, 1),
"face-hair-beard-200.png": (350, 250, 650, 615, 2),
"chest-hand-300.png": (405, 590, 680, 850, 3),
"scroll-hand-300.png": (210, 810, 405, 1050, 3),
"scroll-200.png": (245, 750, 390, 1100, 2),
"upper-background-100.png": (0, 0, 1060, 500, 1),
"middle-background-100.png": (0, 400, 1060, 1000, 1),
"lower-background-100.png": (0, 1000, 1060, 1484, 1),
}
for name, (left, top, right, bottom, scale) in crops.items():
crop = candidate.crop((left, top, right, bottom))
if scale != 1:
crop = crop.resize(
(crop.width * scale, crop.height * scale), Image.Resampling.NEAREST
)
crop.save(out / name)
independent = Image.open(SOURCE / "art-native-candidate-01.png").convert("RGB")
parent = Image.open(SOURCE / "art-native-candidate-02.png").convert("RGB")
current = candidate.convert("RGB")
board = Image.new("RGB", (1060, 540), "#11161c")
draw = ImageDraw.Draw(board)
draw.text((10, 8), "Candidate 01", fill="#f4ead4", font=FONT)
draw.text((365, 8), "Candidate 02", fill="#f4ead4", font=FONT)
draw.text((720, 8), "Candidate 03", fill="#f4ead4", font=FONT)
board.paste(independent.resize((330, 462), Image.Resampling.LANCZOS), (10, 50))
board.paste(parent.resize((330, 462), Image.Resampling.LANCZOS), (365, 50))
board.paste(current.resize((330, 462), Image.Resampling.LANCZOS), (720, 50))
board.save(out / "lineage-comparison.png")
print("Wrote BP-015 art-review evidence")