#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""sheet_kandidat.py <out.jpg> <file1> <file2> ... — contact sheet besar untuk QC pilihan foto."""
import os, sys
from PIL import Image, ImageDraw

IMG = "/home/mantapman/.hermes/profiles/atun/workspace/openclaw-img"
out = sys.argv[1]
files = sys.argv[2:]
cols, tw, th = 3, 620, 466
rows = (len(files) + cols - 1) // cols
sheet = Image.new("RGB", (cols * tw, rows * (th + 26)), "white")
d = ImageDraw.Draw(sheet)
for i, f in enumerate(files):
    im = Image.open(os.path.join(IMG, f)).convert("RGB")
    im.thumbnail((tw, th))
    x = (i % cols) * tw
    y = (i // cols) * (th + 26)
    sheet.paste(im, (x, y))
    d.text((x + 6, y + th + 6), f, fill="black")
sheet.save(out, quality=88)
print(out, sheet.size)
