Turn photos of handwritten slides into a clean black-on-white 16:9 PDF.
Per image: auto-rotate upright, crop to 16:9 around the ink (keeps all text in frame, including anything past the four corner guide-dots), posterize to black text on white, then assemble a multi-page PDF in the order the files are given.
uv run slidify.py *.jpeg -o slides.pdfDependencies (numpy, pillow, scipy) are declared in a PEP 723 header at
the top of slidify.py, so uv run installs them automatically — nothing to
set up, nothing installed system-wide.
Images are processed in the order listed on the command line. A shell glob
sorts lexically, which matches the signal-...jpeg, signal-..._002.jpeg, ...
numbering. To control order, list files explicitly.
-o, --output— output PDF path (defaultslides.pdf).--png-dir DIR— also write per-slide PNGs intoDIR.--rotate DEG— force a fixed rotation (degrees CCW) instead of auto.--ink-threshold N— how much darker than local paper counts as ink (default 26). Lower if faint pencil is dropped; raise if paper noise shows.--margin F— breathing room around the ink as a fraction (default 0.06).--dpi N— PDF resolution (default 200).
- Rotate. Portrait photos are rotated 90° CCW to landscape; already-
landscape images are left alone. Override with
--rotate. - Crop to 16:9. The ink bounding box (all handwriting + the corner dots) is found, given a margin, expanded to exactly 16:9, and clamped inside the image. Driving the crop from the ink extent guarantees no text is cut off.
- Posterize. The paper background is estimated with a large Gaussian blur and subtracted, cancelling uneven lighting; the remaining darkness is ramped so ink goes black and paper goes white.