-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage_scan_pid.sh
executable file
·65 lines (48 loc) · 1.22 KB
/
image_scan_pid.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
participant_id="$1"
today=`date +%Y-%m-%d`
# NOTE: These are overwritten below.
#device="fujitsu:fi-6240dj:5826"
device="fujitsu:fi-6240dj:13472"
source="ADF Duplex"
dpi=300
if [ "$2" == "flatbed" ]; then
source="Flatbed"
fi
if [ ! -f ~/.nlst-scan-device ]; then
echo "Looking for scanner, please wait..."
device=$(scanimage -L | sed -e 's/device `//' | sed -e "s/'.*//")
echo "Found device: $device"
echo -n "$device" > ~/.nlst-scan-device
else
device=`cat ~/.nlst-scan-device`
fi
if [ "${participant_id}" != "" ]; then
if [ ! -d ~/Scans ]; then
mkdir ~/Scans
fi
if [ ! -d ~/Scans/${participant_id} ]; then
mkdir ~/Scans/${participant_id}
fi
filebase="${participant_id}_${today}"
pushd ~/Scans/${participant_id} > /dev/null
lastscan=$(ls | sed -e 's/.tif//' | sort -n | tail -n 1 )
if [ "$lastscan" == "" ]; then
nextnum=1
else
nextnum=$(($lastscan + 1))
fi
scanimage --device-name="$device" \
--format=tiff \
--batch=$filebase_%d.tif \
--batch-increment=1 \
--batch-start $nextnum \
--progress \
--resolution=${dpi}dpi \
--source="${source}" \
--threshold=100 \
--mode="Lineart"
file_size=$(stat -c%s $nextnum.tif)
echo $file_size > ~/.last_scan_size
popd > /dev/null
fi