Fix unsuccessful scan issue and optimize postprocessing

This commit is contained in:
Timo Tomasini 2023-07-25 23:20:35 +02:00
parent 5031b15fdf
commit c00a918ae2
1 changed files with 12 additions and 9 deletions

View File

@ -7,20 +7,27 @@ DATE=$(date +"%Y-%m-%dT%H%M%S")
outdir=/var/spool/scan/out
outname=$DATE.pdf
tmpdir=/tmp/scan-$RANDOMNUMBER
rotatepagesthreshold=10.0
cloudsendpass=""
cloudsendurl=""
source $SCRIPTPATH/scan.script.env
clean_up() {
echo "##### Cleaning up $tmpdir #####"
rm -rf $tmpdir
}
echo "###### Begin of $SCANBD_ACTION for device $SCANBD_DEVICE ######"
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 --device-name $SCANBD_DEVICE --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
#scanimage --device-name $SCANBD_DEVICE --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=$tmpdir/p%03d.tiff
scanimage --device-name $SCANBD_DEVICE --format tiff --mode Color --source "ADF Duplex" --resolution 300 --brightness 16 --buffermode On --page-width 210mm --page-height 297mm --ald=no --swcrop=no --swdespeck 2 --swskip 8% --batch=$tmpdir/p%03d.tiff
if [ ! -f "$tmpdir/p001.pdf" ]; then
if [ ! -f "$tmpdir/p001.tiff" ]; then
echo "#### Scan was not successful, aborting ... ####"
clean_up
exit 1
fi
@ -30,7 +37,7 @@ tiff2pdf -o $tmpdir/tiff2pdf.pdf -z -u m -p "A4" -F $tmpdir/combined.tiff
echo "########## OCRing and optimizing PDF ##########"
mkdir -p $outdir
ocrmypdf -l eng+deu --rotate-pages --deskew --clean $tmpdir/tiff2pdf.pdf $outdir/$outname
ocrmypdf -l eng+deu --deskew --clean --rotate-pages --rotate-pages-threshold $rotatepagesthreshold $tmpdir/tiff2pdf.pdf $outdir/$outname
echo "############# Attempting upload ###############"
CLOUDSEND_PASSWORD=$cloudsendpass cloudsend -p $outdir/$outname $cloudsendurl
@ -39,9 +46,5 @@ if [ $? -eq 0 ]; then
rm -f $outdir/$outname
fi
echo "##### Cleaning up $tmpdir #####"
rm -rf $tmpdir
clean_up
echo "######## Finished scan $outname ########"