Skip to content

Instantly share code, notes, and snippets.

@e-minguez
Last active April 22, 2016 11:06
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 e-minguez/31929c85898316e4b2e7 to your computer and use it in GitHub Desktop.
Save e-minguez/31929c85898316e4b2e7 to your computer and use it in GitHub Desktop.
#!/bin/bash
mkdir -p {images,final}
cd $1
for i in *.pdf
do
convert -density 400 -flatten ${i} ${i}.png
convert ${i}.png -crop 2550x1780+375+200 -resize 50% ${i}_ok.png
rm -f ${i}.png
convert ${i}_ok.png -shave 1x1 -bordercolor black -border 1 images/${i}.png
rm -f ${i}_ok.png
done
cd images
files=$(ls | head -n8)
j=1
while [ -n "${files}" ]
do
montage -mode concatenate -tile 2x8 ${files} ${j}.png
convert -density 300 -page A4 ${j}.png ../final/${j}.pdf
rm -f ${files} ${j}.png
((j++))
files=$(ls *.png | head -n8)
done
cd ..
rm -Rf images/
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment