Skip to content

Instantly share code, notes, and snippets.

@rbanick
Last active August 29, 2015 14:21
Show Gist options
  • Save rbanick/3b93c0c467eb9286ec6a to your computer and use it in GitHub Desktop.
Save rbanick/3b93c0c467eb9286ec6a to your computer and use it in GitHub Desktop.
Quickly flattening an atlas of vector 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
# This script uses imagemagick and ghostscript.
# Please note: Ghostscript does not automatically come installed with imagemagick. Run 'brew install gs' to install it.
## Atlas Conversion
ls -1 *.pdf | parallel convert -density 150 '{}' -quality 90 -alpha remove '{.}.png'
ls -1 *.pdf | rm '{}'
ls -1 *.png | parallel convert '{}' '{.}.pdf'
mkdir ../Flattened_atlas
mv *.pdf ../Flattened_atlas
echo "Done! Atlas flattened and moved to a new 'Flattened_atlas' folder"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment