#!/bin/bash
yad --title "MyScan" --text "Quel type de document voulez-vous obtenir ?" --button='Image:0' --button="PDF:1" 2>/dev/null
case $? in
1)
type=pdf
;;
0)
type=img
;;
esac
file=`yad --file --save --confirm-overwrite --filename=/home/steph/scan/newImage-\`date +%F-%H-%M-%S\` --title "MyScan" --text "Choisissez la destination" 2>/dev/null`
if [ $type == img ] ; then
scanimage --resolution 600 --jpeg-quality 100 >$file.pnm
convert $file.pnm $file.jpg
rm $file.pnm
fi
if [ $type == pdf ] ; then
i=0
tocontinue=0
while [ $tocontinue == 0 ]; do
((i++))
scanimage --resolution 150 --jpeg-quality 100 --contrast 127 --mode Gray >/tmp/myscan$i.pnm
convert /tmp/myscan$i.pnm /tmp/myscan$i.pdf
rm /tmp/myscan$i.pnm
yad --title="MyScan" --text="Scanner une autre page ?" 2>/dev/null
tocontinue=$?
done
pdftk /tmp/myscan*.pdf cat output $file.pdf
rm /tmp/myscan*.pdf
yad --title="MyScan" --text="Archiver le document ?" 2>/dev/null
if [ $? == 0 ]; then
scp $file.pdf s3:/home/pirate/data/paperless/consume/
fi
fi
konqueror `dirname "$file"` 2>/dev/null &