add scan script for epson, with enabled compression*

This commit is contained in:
2025-07-14 19:16:12 +02:00
parent 4d90dafee2
commit 750223694e

44
scan Executable file
View File

@@ -0,0 +1,44 @@
TEMPDIR=/tmp/scanner/
RET_SCAN=0
RET_MAGICK=-1
FILENAME="UNDEFINED"
if [ ! -d "$TEMPDIR" ]; then
echo "create tempdir as it does not exist"
mkdir $TEMPDIR
echo "mkdir returned: " $?
fi
if [ -d "$TEMPDIR" ]; then
scanimage --tl-x 7 -d utsushi:esci:usb:0x04B8:0x110B --batch="$TEMPDIR/out%d.pnm" \
--source=ADF \
--resolution=200
RET_SCAN=$?
echo "scanimage retured:" $RET_SCAN
else
echo "$TEMPDIR does not exist and could not be created"
fi
#scanimage error 1, 2
#returns on success also 2
if [ $RET_SCAN == 2 ]; then
DATE=$(date +scan_%F-%s)
FILENAME="$TEMPDIR/$DATE.pdf"
magick -compress jpeg -quality 60 -density 150 "$TEMPDIR/out*.pnm" $FILENAME
RET_MAGICK=$?
for pnmFile in "$TEMPDIR/out*.pnm"
do
echo "remove temporary pnm files in $TEMPDIR"
rm $pnmFile
done
fi
if [ $RET_MAGICK == 0 ]; then
echo "magick sucessful converted $FILENAME"
xdg-open $FILENAME
else
echo -e "ERROR: magick returned: " $RET_MAGICK " there sems to be nothing to do\n is the paper inserted?"
fi