summaryrefslogtreecommitdiffstats
path: root/scan-multi
blob: fc6ca33d61137e68c5d4e42d16052e976f4d3820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash

jpeg_quality=70
jpeg_size=1500x1500

time=$(date +%Y-%m-%d_%H%M%S)
scanimage --resolution 200 -b -x 215 -y 297
i=1
while [[ -e "out$i.pnm" ]]; do
	img="out$i.pnm"
	newname="$(printf "%s_%03d" "$time" "$i")"
	convert "$img" -normalize -resize $jpeg_size -quality $jpeg_quality "$newname.jpg" && rm "$img"
	((i++))
done

if [[ $1 = "--pdf" ]]; then
	convert "${time}"_*.jpg -resize $jpeg_size -compress jpeg -quality $jpeg_quality -density 72x72 -repage 595x842 "${time}.pdf" && rm "${time}"_*.jpg
fi