"""python -B grid_plate_325.py EVIDENCE OUT_DIR; create a native-resolution grayscale crop of the two decisive source rows."""
from pathlib import Path
import hashlib,json,sys
from PIL import Image
d=Path(sys.argv[1]);out=Path(sys.argv[2])
p=d/'66.jpg';assert hashlib.sha256(p.read_bytes()).hexdigest()=='aa3f89156756edf8b796a470a14a3db96516ad2fedf1ed98ccabc1a1cddc0335'
cells=json.loads((d/'grid_cells_254.json').read_bytes())['cells'];boxes=[c['bbox'] for c in cells if c['page']==49 and c['row'] in (2,3)];assert len(boxes)==16
rect=(min(b[0] for b in boxes)-15,min(b[1] for b in boxes)-14,max(b[2] for b in boxes)+15,max(b[3] for b in boxes)+14)
im=Image.open(p);assert im.size==(2400,3600);crop=im.crop(rect)
out.mkdir(exist_ok=True,parents=True);crop.convert('L').save(out/'grid_plate_325.png',optimize=True)
