aspect ratio and keep awake

This commit is contained in:
2026-07-18 18:36:51 -04:00
parent 13b210935f
commit 755fa0632c
4 changed files with 100 additions and 13 deletions

View File

@ -92,12 +92,13 @@ def check_layout_combos():
assert ys == sorted(ys), f"pps={pps} spp={spp} strip {strip_i}: not top-to-bottom"
for a, b in zip(rects, rects[1:]):
assert b[1] >= a[1] + a[3], "photos overlap vertically"
# Cell aspect must match the chosen mode.
# Cell aspect must be exactly 4:3 (3:4 when rotated) to match
# the captured photos, within integer rounding of the layout.
cw, ch = rects[0][2], rects[0][3]
if layout["mode"] == "portrait_ccw":
assert ch >= cw, f"portrait_ccw cell not taller than wide"
else:
assert cw >= ch, f"landscape_none cell not wider than tall"
want = 3 / 4 if layout["mode"] == "portrait_ccw" else 4 / 3
assert abs(cw / ch - want) < 0.02, (
f"pps={pps} spp={spp} {layout['mode']}: cell {cw}x{ch} "
f"aspect {cw / ch:.4f} != ~{want:.4f}")
# Footer sits below the column, aligned in x, same width.
for strip_i in range(spp):
@ -121,7 +122,11 @@ def check_layout_combos():
margin=120, photo_gutter=30, strip_gutter=30,
auto_orient=True)
from PIL import Image as _I
sheet = _I.open(out).convert("RGB")
with _I.open(out) as opened:
dpi = opened.info.get("dpi", (0, 0))
assert abs(dpi[0] - 300) <= 1 and abs(dpi[1] - 300) <= 1, \
f"sheet dpi metadata wrong: {dpi} (want ~300)"
sheet = opened.convert("RGB")
assert sheet.size == (page_w, page_h)
for i, r in enumerate(layout["photo_rects"]):