#!/usr/bin/env python3
"""Contact sheet 14 kartu seri uky5 (varian terpilih: rotasi biru/putih/orange) untuk QC visual."""
from PIL import Image, ImageDraw
import importlib.util, os

WS = "/home/mantapman/.hermes/profiles/atun/workspace"
spec = importlib.util.spec_from_file_location("g5", os.path.join(WS, "gen_uky5_quotes.py"))
g5 = importlib.util.module_from_spec(spec)
spec.loader.exec_module(g5)
L = g5.LIST_POSTINGAN

W = 540
cols = 4
rows = (len(L) + cols - 1) // cols
sheet = Image.new("RGB", (W * cols, W * rows), (235, 235, 235))
for i, k in enumerate(L):
    warna = ["biru", "putih", "orange"][i % 3]
    p = os.path.join(WS, f"uky5_output/{k['nama']}_{warna}.png")
    im = Image.open(p).convert("RGB").resize((W - 10, W - 10))
    x, y = (i % cols) * W, (i // cols) * W
    sheet.paste(im, (x + 5, y + 5))
out = os.path.join(WS, "uky5_contact_sheet.png")
sheet.save(out)
print("saved", out, sheet.size)
