Created
July 14, 2019 04:16
-
-
Save z-rui/e8939ba23f90c5ffc46695731263a4af to your computer and use it in GitHub Desktop.
Make a 16-page booklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
size="3300x2550" # 11" x 8" | |
# size="3508x2480" # 297mm x 210mm | |
cvtopts="+append -adaptive-resize $size -gravity center -extent $size -set density 300 -unsharp 0x5+0.3+0" | |
if [[ ! -z $1 ]]; then | |
N=$1 | |
elif [[ $PWD =~ FILE([0-9]+) ]]; then | |
N=${BASH_REMATCH[1]} | |
else | |
echo "Cannot determine files" | |
exit 1 | |
fi | |
page() { | |
printf "$N-%02d.jpg" $1 | |
} | |
cvt() { | |
a=`page $(($1))` | |
b=`page $((17-$1))` | |
if (($1%2)); then | |
rot="" | |
in="$a $b" | |
else | |
rot="-rotate 180" | |
in="$b $a" | |
fi | |
out="out-$1.jpg" | |
echo $in "=>" $out | |
convert $in $cvtopts $rot $out & | |
} | |
for i in {1..8}; do | |
cvt $i | |
done | |
wait | |
convert out-{1..8}.jpg $N.pdf && rm out-{1..8}.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment