Skip to content

Instantly share code, notes, and snippets.

@rbanick
Last active July 15, 2018 13:28
Show Gist options
  • Save rbanick/d8025f79e5cda3f684ca to your computer and use it in GitHub Desktop.
Save rbanick/d8025f79e5cda3f684ca to your computer and use it in GitHub Desktop.
Create thumbnails for a bunch of PDFs
#!/bin/bash
# This will convert PDF atlases to .pngs and then convert them back to .PDF, now rasterized.
# Use this script to flatten PDF exports from QGIS so you can generate thumbnails for the Mapfolio
### DEPENDENCIES
# This script uses parallel, imagemagick and ghostscript.
# To install: brew install imagemagick && brew install parallel && brew install gs
# Please note: Ghostscript does not automatically come installed with imagemagick.
## All files thumbnail conversion
ls -1 *.pdf | parallel convert '{}' -colorspace RGB -resize 600x400 -border 158.5x0 -background white -alpha remove -opaque none '{.}_thumb.jpg'
ls -1 *.pdf | parallel convert '{}' -colorspace RGB -resize 300x200 -border 79.5x0 -background white -alpha remove -opaque none '{.}_small.jpg'
## The -border adds grey spaces to the side for correct viewing the mapfolio.
## NOTE: The border widths specified apply to *EACH SIDE*, so in this case I had to halve the desired width to get the correct overall width.
mkdir ../thumbnails
mv *.jpg ../thumbnails
echo "Done! Files moved to a new 'Thumbnails' folder"
@rbanick
Copy link
Author

rbanick commented May 12, 2015

still need to modify this so that it runs on PDF | PNG | all other image types at the same time instead of just PDF. Should be simple but my knowledge of such things is basic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment