Initial commit
This commit is contained in:
commit
190434c039
2 changed files with 40 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*.env
|
||||
out/
|
38
scan.script
Executable file
38
scan.script
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash
|
||||
|
||||
outdir=/var/spool/scan/out
|
||||
RANDOMNUMBER=$(cat /dev/urandom | tr -dc A-Za-z0-9 | head -c${1:-16})
|
||||
DATE=$(date +"%Y-%m-%dT%H%M%S")
|
||||
outname=$DATE.pdf
|
||||
tmpdir=/tmp/scan-$RANDOMNUMBER
|
||||
cloudsendpass=""
|
||||
cloudsendurl=""
|
||||
source ./scan.script.env
|
||||
|
||||
echo "######## TMPDIR $tmpdir ########"
|
||||
mkdir $tmpdir
|
||||
|
||||
echo "################## Scanning ###################"
|
||||
#scanimage --format tiff --mode Color --source "ADF Duplex" --resolution 300 --buffermode On --page-height 1000mm --ald=yes --swcrop=yes --swdeskew=yes --swdespeck 2 --swskip 8% --batch=p%03d.tiff
|
||||
scanimage --format tiff --mode Color --source "ADF Duplex" --resolution 300 --buffermode On --page-width 210mm --page-height 297mm --ald=no --swcrop=no --swdespeck 1 --swskip 8% --batch=$tmpdir/p%03d.tiff
|
||||
|
||||
echo "############# Converting to PDF ###############"
|
||||
tiffcp -c lzw $tmpdir/*.tiff $tmpdir/combined.tiff
|
||||
tiff2pdf -o $tmpdir/tiff2pdf.pdf -z -u m -p "A4" -F $tmpdir/combined.tiff
|
||||
|
||||
echo "########## OCRing and optimizing PDF ##########"
|
||||
ocrmypdf -l eng+deu --rotate-pages --deskew --clean $tmpdir/tiff2pdf.pdf $outdir/$outname
|
||||
|
||||
echo "############# Attempting upload ###############"
|
||||
CLOUDSEND_PASSWORD=$cloudsendpass cloudsend -p $outdir/$outname $cloudsendurl
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
rm -f $outdir/$outname
|
||||
fi
|
||||
|
||||
|
||||
echo "######## Cleaning up $tmpdir ########"
|
||||
rm -rf $tmpdir
|
||||
|
||||
echo "######## Finished scan $outname ########"
|
||||
|
Loading…
Reference in a new issue