diff --git a/README.md b/README.md index 86a4b6e..da6274a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,20 @@ # Scan2PDF -Kleine Sammlung, um aus einem Scan (TIFF) ein Sandwich-PDF zu machen. \ No newline at end of file +Kleine Sammlung, um aus einem Scan (TIFF) ein Sandwich-PDF zu machen. + +## Benötigte Pakete + +``` +# dpkg -l \*tesseract\* \*incron\* | grep "^ii" +ii incron 0.5.12-1+deb10u1 amd64 cron-like daemon which handles filesystem events +ii libtesseract4:amd64 4.0.0-2 amd64 Tesseract OCR library +ii tesseract-ocr 4.0.0-2 amd64 Tesseract command line OCR tool +ii tesseract-ocr-deu 1:4.00~git30-7274cfa-1 all tesseract-ocr language files for German +ii tesseract-ocr-eng 1:4.00~git30-7274cfa-1 all tesseract-ocr language files for English +ii tesseract-ocr-osd 1:4.00~git30-7274cfa-1 all tesseract-ocr language files for script and orientation +``` + +## incron + +Mit `incrontab -e` (als User "scanner") kann festgelegt werden, wann was passieren soll - abhängig von Dateisystem-Operationen. Ein Beispiel findet sich in `incrond.txt`. + diff --git a/incrond.txt b/incrond.txt new file mode 100644 index 0000000..aa71ed2 --- /dev/null +++ b/incrond.txt @@ -0,0 +1,2 @@ +/home/scanner/FTP IN_CLOSE_WRITE /home/scanner/bin/sandwich_pdf.sh $@/$# + diff --git a/sandwich_pdf.sh b/sandwich_pdf.sh new file mode 100755 index 0000000..d9a8038 --- /dev/null +++ b/sandwich_pdf.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo Bitte Dateinamen als Argument übergeben! + exit 1 +fi + +while [ -n "$1" ]; do + FF=$1 + if echo "${FF}" | grep -q '\.tif$'; then + tesseract -l deu ${FF} ${FF/.tif/} pdf + else + echo "Skipped: $FF" + fi + shift +done +