reenable sidebar merge
[dotfiles.git] / x / .local / bin / thumbnailer.sh
1 #!/bin/bash
2
3 PAGERESIZE=50%
4
5 log () {
6 echo "$@" >&2
7 }
8
9 if [ "$#" -ne 2 ]
10 then
11 log "Convert all pdf pages to a montage"
12 log "Usage: $0 INPUT.pdf OUTPUT.png"
13 exit 1
14 fi
15 log "Processing $1 to $2"
16
17 TMPDIR="$(mktemp -d)"
18 log "Temp directory created in $TMPDIR"
19
20 NUMPAGES=$(identify "$1" | wc -l)
21 log "$NUMPAGES detected"
22
23 log -n "Processing page: "
24 for ((p=0;p<$NUMPAGES;p++))
25 do
26 convert "$1"[$p] -resize $PAGERESIZE $TMPDIR/$p.png
27 log -n "$p, "
28 done
29 log "done!"
30
31 montage -geometry +0+0 $TMPDIR/*.png "$2"
32 log "Montaging done"
33
34 rm -r $TMPDIR
35 log "Cleaned up"
36
37 log "Done"