# Mako: lays the lookalike renders (mk_lookalike.py) next to the user's sheet, panel by panel (plain Python + Pillow): # previews/compare/lookalike.png: each row the sheet's view on the left, the model in the same view on the right. import os from PIL import Image, ImageDraw HERE = os.path.dirname(os.path.abspath(__file__)) D = os.path.join(os.path.dirname(HERE), "previews", "compare") BP = Image.open(os.path.join(os.path.dirname(HERE), "reference", "user_reference.webp")).convert("RGB") BOX = {"top": (30, 40, 970, 520), "side": (30, 530, 970, 1065), "front": (970, 30, 1410, 530), "rear": (960, 545, 1410, 1030)} rows = [] for name, b in BOX.items(): rp = os.path.join(D, "lk_%s.png" % name) if not os.path.exists(rp): continue ref = BP.crop(b) r = Image.open(rp).convert("RGBA").resize(ref.size, Image.LANCZOS) white = Image.new("RGBA", ref.size, (255, 255, 255, 255)) model = Image.alpha_composite(white, r).convert("RGB") row = Image.new("RGB", (ref.width * 2 + 12, ref.height), "white") row.paste(ref, (0, 0)); row.paste(model, (ref.width + 12, 0)) ImageDraw.Draw(row).text((ref.width + 20, 6), "MODEL " + name.upper(), fill=(200, 30, 30)) rows.append(row) if rows: top2 = rows[:2] W = max(r.width for r in rows[:2]) H = sum(r.height for r in rows[:2]) left = Image.new("RGB", (W, H), "white"); y = 0 for r in rows[:2]: left.paste(r, (0, y)); y += r.height right = None if len(rows) > 2: W2 = max(r.width for r in rows[2:]); H2 = sum(r.height for r in rows[2:]) right = Image.new("RGB", (W2, H2), "white"); y = 0 for r in rows[2:]: right.paste(r, (0, y)); y += r.height sheet = Image.new("RGB", (left.width + (right.width + 20 if right else 0), max(left.height, right.height if right else 0)), "white") sheet.paste(left, (0, 0)) if right: sheet.paste(right, (left.width + 20, 0)) sheet.save(os.path.join(D, "lookalike.png")) print("ok", len(rows))