#!/usr/bin/env python3
"""QC carousel 14 Okt: probe warna bg tiap slide + contact sheet."""
from PIL import Image
import os

D = "/home/mantapman/.hermes/profiles/atun/workspace/openclaw-img"
files = [f"{D}/ss_car10_promptai_{i:02d}.jpg" for i in range(1, 11)]

print("=== warna bg (pixel 8,8) ===")
war = []
for f in files:
    im = Image.open(f).convert("RGB")
    px = im.getpixel((8, 8))
    label = "PUTIH" if min(px) >= 235 else ("NAVY/BIRU" if px[2] > 80 and px[2] > px[0] else "LAIN")
    war.append(label)
    print(f"{os.path.basename(f)}  size={im.size}  px={px}  -> {label}")

print()
print("urutan:", " → ".join(war))
harap = ["PUTIH" if i % 2 == 1 else "NAVY/BIRU" for i in range(1, 11)]
print("harap :", " → ".join(harap))
ok = all(a == b for a, b in zip(war, harap))
print("pola selang-seling genap (putih dulu):", "✅" if ok else "⚠️ TIDAK COCOK")

# contact sheet 5 kolom x 2 baris
cols, rows = 5, 2
thumb_w = 420
th = Image.open(files[0])
ratio = thumb_w / th.size[0]
thumb_h = int(th.size[1] * ratio)
sheet = Image.new("RGB", (cols * thumb_w, rows * thumb_h), (24, 24, 24))
for i, f in enumerate(files):
    im = Image.open(f).convert("RGB").resize((thumb_w, thumb_h), Image.LANCZOS)
    sheet.paste(im, ((i % cols) * thumb_w, (i // cols) * thumb_h))
out = "/tmp/car10_promptai_14okt_sheet.jpg"
sheet.save(out, quality=88)
print("\ncontact sheet:", out)
