# rsnaps Capture a raw snap stream (scans or pictures) through a locally running webapp. *rsnaps* is a simple webapp for local deployment on a machine with access to one or more scanner devices, or cameras with Canon CHDK. Users can start scan jobs and the scanned images will be put into a local directory with a serial number in the name. Users can see the list of previously scanned images and redo previous scans. The scanned images are stored in PNG format and few metadata are added to them: * the name of the operator doing the scan * the ID of the unit/batch of material that is being scanned * the date and time of the scan * the device used for scanning Limitations: * no concurrency: only one instance of rsnaps can run on a machine * A4 (181x256) ## Prerequisites Debian Linux with these packages installed * python3-sane * python3-aiohttp * python3-aiohttp-jinja2 ``` apt install sane python3-sane python3-aiohttp python3-aiohttp-jinja2 ``` ### PDF creation Install jbig2 from https://github.com/agl/jbig2enc (cf. https://ocrmypdf.readthedocs.io/en/latest/jbig2.html). You'll need these dependencies: TODO Note: For jbig2 compression architecture amd64 is required. ### OCR `apt install pngquant ocrmypdf` and required tesseract language packages, e.g. `tesseract-ocr-eng`, `tesseract-ocr-deu`, ... ### Page rotationa `apt install imagemagick` ## Setup ### User and software ``` adduser --disabled-login --home /srv/rsnaps --ingroup scanner su - rsnaps git clone _______TODO_________ repo ... TODO ``` ### systemd integration Put a systemd service unit in `/etc/systemd/system/rsnaps.service`: ``` [Unit] Description=rsnaps local sanning service [Service] Type= ExecStart= [Install] WantedBy=multi-user.target ``` ``` systemctl daemon-reload systemctl enable rsnaps.service systemctl start rsnaps.service ``` ## Development Useful resources: * [python-sane docs](https://python-sane.readthedocs.io/en/latest/) * [example.py](https://github.com/python-pillow/Sane/blob/main/example.py) * [python-sane source](https://github.com/python-pillow/Sane/) * [SANE standard](https://sane-project.gitlab.io/standard/) ## TODO * handle timeout of subprocess calls * lazy image loading: https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API https://css-tricks.com/the-complete-guide-to-lazy-loading-images/ https://web.dev/lazy-loading-images/ https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading