Crop a scan, straighten it, and print it at exactly the size the real document is.
Runs on your own machine. Nothing you scan gets uploaded.
You scanned a passport, an ID card, a certificate. Now you need it on A4, cropped clean, straight, and at exactly the size the real thing is, because the office you are sending it to will reject it otherwise.
Every scanning app crops. Almost none of them get the size right.
A scanner writes the scanned area into a PDF at 1 to 1, so the real size falls straight out of the pixel count. No preset, no guessing, no asking you what the object is.
A passport in a clear sleeve has no brightness step to threshold, so ordinary edge detection grabs the printing instead. Segment Anything 2 finds objects by what they are.
A crop has to be a rectangle, so the corners pick up whatever sits outside the curve. cropsize traces the real outline and clears those corners to white.
| Scan | cropsize reads | Off by |
|---|---|---|
| Passport on white | 126.1 by 177.0 mm | 1.1 and 1.0 mm |
| Passport in a plastic sleeve | 127.2 by 175.4 mm | 2.2 and 0.6 mm |
| ID card on a flatbed | 85.6 by 53.9 mm | 0.0 and 0.1 mm |
| Sample document | 104.9 by 147.9 mm | 0.1 and 0.1 mm |
A passport spread is 125 by 176 mm by international standard, so these are measured against a known answer. The same content scanned at 150, 300, 600 and 1200 dpi measures the same, because a PDF has no dpi of its own and the page geometry is what carries the size.
git clone https://github.com/okturan/cropsize.git
cd cropsize
./run.sh
Open localhost:8077 and click Try the sample. That is the whole tour.
For real work add the model, then restart:
./.venv/bin/pip install -r requirements-sam.txt
Weights come from Hugging Face the first time you use them, about 320 MB, and stay on disk after that.