"""Side-by-side A/B sheet: full frame on top, zoomed crop underneath. python3 compare.py --title "voxel 0.3 vs 0.2" \ "voxel 0.3=out/preview_g5_00.png" "voxel 0.2=out_crisp/preview_g5_00.png" The zoom row is the point: fusing and crease softness are invisible at full frame and obvious at 3x. Panes must share a camera for the crop to line up, which the cube renders do. """ import argparse import os from PIL import Image, ImageDraw, ImageFont FONT = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" BOLD = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" PANEL_W = 760 def parse_pane(text): if "=" not in text: raise SystemExit(f"expected label=path, got {text!r}") label, path = text.split("=", 1) if not os.path.exists(path): raise SystemExit(f"missing {path}") return label, path def main(): parser = argparse.ArgumentParser() parser.add_argument("panes", nargs="+") parser.add_argument("--title", default="comparison") parser.add_argument("--out", default="compare.png") parser.add_argument("--crop", default="0.36,0.24,0.80,0.62", help="left,top,right,bottom as fractions") args = parser.parse_args() panes = [parse_pane(text) for text in args.panes] left, top, right, bottom = (float(v) for v in args.crop.split(",")) full, zoom = [], [] for _, path in panes: image = Image.open(path).convert("RGB") height = int(image.height * PANEL_W / image.width) full.append(image.resize((PANEL_W, height), Image.LANCZOS)) box = (int(left * image.width), int(top * image.height), int(right * image.width), int(bottom * image.height)) zoom.append(image.crop(box).resize((PANEL_W, height), Image.LANCZOS)) gap, header = 10, 96 width = PANEL_W * len(panes) + gap * (len(panes) + 1) height = header + full[0].height * 2 + gap * 3 sheet = Image.new("RGB", (width, height), (28, 29, 31)) draw = ImageDraw.Draw(sheet) draw.text((gap, 12), args.title, font=ImageFont.truetype(BOLD, 26), fill=(238, 238, 238)) draw.text((gap, 46), "top: full frame ยท bottom: " "same crop, not resampled from the other pane", font=ImageFont.truetype(FONT, 16), fill=(150, 152, 155)) label_font = ImageFont.truetype(FONT, 18) for index, (label, _) in enumerate(panes): x = gap + index * (PANEL_W + gap) draw.text((x + 2, 70), label, font=label_font, fill=(205, 205, 208)) sheet.paste(full[index], (x, header)) sheet.paste(zoom[index], (x, header + full[index].height + gap)) sheet.save(args.out) print(f"wrote {args.out} ({sheet.width}x{sheet.height})") if __name__ == "__main__": main()