bundles/scansnap: do ocr in a separate process to speed up scanning
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
d193ec8ef3
commit
5d4ca086e6
4 changed files with 33 additions and 14 deletions
21
bundles/scansnap/files/ocr.sh
Normal file
21
bundles/scansnap/files/ocr.sh
Normal 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"
|
|
@ -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"
|
|
||||||
|
|
|
@ -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"
|
||||||
|
|
|
@ -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',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue