Skip to content

Instantly share code, notes, and snippets.

@tenkabuto
Last active May 23, 2018 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenkabuto/4059f3aadafc0c3692e17e3663ae6f8a to your computer and use it in GitHub Desktop.
Save tenkabuto/4059f3aadafc0c3692e17e3663ae6f8a to your computer and use it in GitHub Desktop.
Requires ImageMagick and pdftk. Produced by @court-jus. Takes an 8 page PDF and transforms it into a PocketMod booklet! Found at: https://boardgamegeek.com/thread/803592/best-way-make-pocketmod
#!/bin/bash
filename=$1
basefilename=$(basename ${filename})
tmpdir=$(mktemp -d -t)
cp ${filename} ${tmpdir}/
cd ${tmpdir}
pdftk ${basefilename} burst
for file in pg*pdf; do convert -density 300 ${file} ${file/pdf/jpg}; done
# Upside down first for fold on top
montage pg_000{1,2,3,4}.jpg \
-rotate 180 pg_000{5,6,7,8}.jpg \
-geometry 2480x3508+0+0 output.jpg
cd -
convert -density 300 ${tmpdir}/output.jpg your_pocketmod_output.pdf
rm -rf ${tmpdir}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment