bundles/scansnap: do ocr in a separate process to speed up scanning
All checks were successful
bundlewrap/pipeline/head This commit looks good

This commit is contained in:
Franzi 2021-05-24 10:24:01 +02:00
parent d193ec8ef3
commit 5d4ca086e6
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 33 additions and 14 deletions

View file

@ -0,0 +1,21 @@
#!/bin/bash
set -euo pipefail
DATE=$(date +%F_%H-%M-%S)
cd "$1"
convert *.tiff no_ocr.pdf
ocrmypdf -l deu no_ocr.pdf has_ocr.pdf
rm -f *.tiff
rm -f no_ocr.pdf
chown nobody:nogroup has_ocr.pdf
mv has_ocr.pdf "/srv/scansnap/${DATE}.pdf"
cd /
rm -r "$1"

View file

@ -2,17 +2,8 @@
set -euo pipefail set -euo pipefail
DATE=$(date +%F_%H-%M-%S) OUTFILE=$(mktemp -d)
OUTFILE="/tmp/${DATE}"
scanimage --source 'ADF Duplex' --format tiff --mode Gray --resolution 300 --page-width 210 --page-height 297.3 -x 210 -y 297.3 --batch=${OUTFILE}_p%04d.tiff scanimage --source 'ADF Duplex' --format tiff --mode Gray --resolution 300 --page-width 210 --page-height 297.3 -x 210 -y 297.3 --batch=${OUTFILE}/p%04d.tiff
convert ${OUTFILE}_*.tiff ${OUTFILE}.pdf /etc/scanbd/scripts/ocr.sh "$OUTFILE" &
ocrmypdf -l deu ${OUTFILE}.pdf ${OUTFILE}.OCR.pdf
rm -f ${OUTFILE}_*.tiff
rm -f ${OUTFILE}.pdf
chown nobody:nogroup "${OUTFILE}.OCR.pdf"
mv "${OUTFILE}.OCR.pdf" "/srv/scansnap/${DATE}.pdf"

View file

@ -35,8 +35,8 @@ global {
action scan { action scan {
filter = "^scan.*" filter = "^scan.*"
numerical-trigger { numerical-trigger {
from-value = 1 from-value = 0
to-value = 0 to-value = 1
} }
desc = "Scan to file" desc = "Scan to file"
script = "scan.sh" script = "scan.sh"

View file

@ -19,10 +19,17 @@ files = {
'svc_systemd:scanbd:restart', 'svc_systemd:scanbd:restart',
}, },
}, },
'/etc/scanbd/scripts/ocr.sh': {
'mode': '0755',
'needs': {
'directory:/srv/scansnap',
},
},
'/etc/scanbd/scripts/scan.sh': { '/etc/scanbd/scripts/scan.sh': {
'mode': '0755', 'mode': '0755',
'needs': { 'needs': {
'directory:/srv/scansnap', 'directory:/srv/scansnap',
'file:/etc/scanbd/scripts/ocr.sh',
}, },
}, },
} }