|
|
@@ -1,8 +1,11 @@
|
|
|
#!/bin/env bash
|
|
|
|
|
|
export GDK_BACKEND=x11
|
|
|
-export SANE_DEFAULT_DEVICE='epsonds:libusb:001:006' # Specify device to avoid startup delays and scanning slowness.
|
|
|
+export SANE_DEFAULT_DEVICE='epsonds:libusb:001:005'
|
|
|
+# Specify device to avoid startup delays and scanning slowness.
|
|
|
+# scanimage --list-devices
|
|
|
|
|
|
+# See if file exists, add a number to name if needed.
|
|
|
function check_filename {
|
|
|
path=$1
|
|
|
folder=$(dirname "$path")
|
|
|
@@ -21,21 +24,33 @@ function check_filename {
|
|
|
}
|
|
|
export -f check_filename # Make available to run_scan's command substitution
|
|
|
|
|
|
-# positional arguments: 1-folder 2-prefix 3-format 4-papersize 5-resolution 6-colormode
|
|
|
+# Run scanner. arguments: 1-folder 2-prefix 3-format 4-papersize 5-resolution 6-colormode
|
|
|
function run_scan {
|
|
|
|
|
|
# Paper size.
|
|
|
+ landscape=false
|
|
|
case $4 in
|
|
|
A4)
|
|
|
x=210
|
|
|
y=297
|
|
|
;;
|
|
|
+ A4R)
|
|
|
+ x=210
|
|
|
+ y=297
|
|
|
+ landscape=true
|
|
|
+ ;;
|
|
|
A5)
|
|
|
x=148
|
|
|
y=210
|
|
|
;;
|
|
|
A5R)
|
|
|
- x=210 # currently removed A5R because sane epson backend throws an out of memory error.
|
|
|
+ if [[ $5 == "150" ]] then
|
|
|
+ # Force A4 instead, and cut later.
|
|
|
+ # Sane epson backend throws an out of memory error at ~A5R 150DPI.
|
|
|
+ x=210
|
|
|
+ y=297
|
|
|
+ fi
|
|
|
+ x=210
|
|
|
y=148
|
|
|
;;
|
|
|
esac
|
|
|
@@ -47,15 +62,17 @@ function run_scan {
|
|
|
tempname="./temp-$(date +%s).png"
|
|
|
scanimage --mode=$6 --resolution=$5 -x $x -y $y --format=png --output-file=$tempname | \
|
|
|
yad --progress --text="Scanning to PNG..." --width=300 --no-buttons --auto-close
|
|
|
+ if [[ $landscape == true ]] then
|
|
|
+ convert $tempname -rotate 90 $tempname
|
|
|
+ fi
|
|
|
|
|
|
case $3 in
|
|
|
png)
|
|
|
- mv $tempname $filename
|
|
|
+ cp $tempname $filename
|
|
|
;;
|
|
|
jpg)
|
|
|
convert -quality 85 $tempname $filename | \
|
|
|
yad --progress --text="Converting to $3..." --width=300 --no-buttons --auto-close
|
|
|
- rm $tempname
|
|
|
;;
|
|
|
pdf)
|
|
|
if [[ $6 != "Lineart" ]] then
|
|
|
@@ -67,28 +84,33 @@ function run_scan {
|
|
|
fi
|
|
|
convert $tempname $filename | \
|
|
|
yad --progress --text="Converting to $3..." --width=300 --no-buttons --auto-close
|
|
|
- rm $tempname
|
|
|
;;
|
|
|
esac
|
|
|
+
|
|
|
+ yad --picture --title="Preview" --size=fit --width=750 --height=1000 --filename=$tempname
|
|
|
+ rm $tempname
|
|
|
}
|
|
|
export -f run_scan # Make function available to yad button command.
|
|
|
|
|
|
# Display scan-dialog.
|
|
|
yad --form --orient=hor --maximized --width=750 --height=250 --columns=3 \
|
|
|
--title="Scanning Options" \
|
|
|
- --field="Scan Folder:SFL" /mnt/public \
|
|
|
+ --field="Scan Folder:SFL" /mnt/public/scans \
|
|
|
--field="Filename Prefix:SFL" scan \
|
|
|
--field="File format:CB" jpg\!png\!pdf \
|
|
|
- --field="Paper Size:CB" A4\!A5 \
|
|
|
- --field="Resolution (DPI):CB" 75\!^150\!300\!600\!1200 \
|
|
|
+ --field="Paper Size:CB" A4\!A4R\!A5\!A5R \
|
|
|
+ --field="Resolution (DPI):CB" 75\!150\!^300\!600\!1200 \
|
|
|
+ --field="...:BTN" "" \
|
|
|
--field="Scan Buttons:BTN" "" \
|
|
|
--field="Colour:FBTN" 'bash -c "run_scan %1 %2 %3 %4 %5 Color"' \
|
|
|
--field="Grayscale:FBTN" 'bash -c "run_scan %1 %2 %3 %4 %5 Gray"' \
|
|
|
--field="B&W:FBTN" 'bash -c "run_scan %1 %2 %3 %4 %5 Lineart"' \
|
|
|
--field="...:BTN" "" \
|
|
|
+ --field="...:BTN" "" \
|
|
|
--field="Presets:BTN" "" \
|
|
|
--field="Art (Colour PNG):FBTN" 'bash -c "run_scan %1 art png %4 %5 Color"' \
|
|
|
--field="Art (Colour JPG):FBTN" 'bash -c "run_scan %1 art jpg %4 %5 Color"' \
|
|
|
+ --field="Doc (Colour PDF):FBTN" 'bash -c "run_scan %1 doc pdf %4 %5 Color"' \
|
|
|
--field="Doc (Gray PDF):FBTN" 'bash -c "run_scan %1 doc pdf %4 %5 Gray"' \
|
|
|
--field="Doc (B&W PDF):FBTN" 'bash -c "run_scan %1 doc pdf %4 %5 Lineart"' \
|
|
|
--no-buttons --buttons-layout=center
|