Skip to content

Instantly share code, notes, and snippets.

Created Oct 20, 2017
What would you like to do?
Batch compress PDFs for Omeka
# This requires the use of GhostScript
# On macOS, the easiest way to get started is install with Homebrew
# brew install ghostscript
# This file should live in the directory that contains the PDFs. From
# the command line, just running `bash` will compress the PDFs
# and fix any issues that might be present with JPEG2000 images. The
# compression process should preserve the OCR and will likely reduce the
# size of the PDF as well.
# Flattened files will be appended with `.flatened.pdf` and will not overwrite
# the original PDFs.
for files in *.pdf
gs -dBATCH -dNOPAUSE -dSAFER -sDEVICE=pdfwrite -sOutputFile=$files.flattened.pdf $files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment