Repository navigation
Conversation
main.py always ran OCR, printed the text and opened GUI windows, with no way to save the scan, and crashed with an unhelpful error for a missing file. The CLI now lives in document_scanner/cli.py (main.py is a thin wrapper): - Takes one or more images as positional arguments (--image still works). - Saves each scan as <image>_scanned.png by default, or to -o/--output. - --no-save, --no-threshold, --no-rotate, --ocr and --show options. OCR and windows are now opt-in. - Unreadable or missing images are reported and the rest still scanned; exit status 1 if any image failed, 2 for invalid arguments. - Without Tesseract, auto-rotation is skipped with a warning and --ocr is an error. --show warns instead of aborting when there is no display. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013dqF6Adef93KhGwqLnxKPQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Before this change,
main.pyalways ran OCR, printed the text and opened GUI windows. It had no way to save the scan, and a missing file crashed it with an unhelpful error.The CLI now lives in
document_scanner/cli.pyasmain(argv), andmain.pyis a thin wrapper. This lets the packaging PR point an installed command straight at it.IMAGE ...--imagestill works for compatibility)-o/--output PATH<image>_scanned.png--no-save--no-threshold--no-rotate--ocr==> file <==headers for several photos--showBehaviour changes
--ocris an error.--showwarns instead of letting OpenCV's Qt backend abort the process (exit 134). I reproduced that abort on a machine without a display..gitignore: ignores*_scanned.png, so scans of the sample photos aren't committed by accident.Tests
tests/test_cli.pyadds 16 tests. They cover:-owith--no-threshold--imageoption--no-rotateand--no-save--showwith and without a displaymain.pyon the sample receipt, checking OCR text and upright outputTesseract and the GUI are mocked except in the end-to-end test.
Test plan
python -m pytest: 94 passed on Python 3.14 and 3.11.--showwithout a display.🤖 Generated with Claude Code
https://claude.ai/code/session_013dqF6Adef93KhGwqLnxKPQ
Generated by Claude Code