Skip to content

Instantly share code, notes, and snippets.

@SalvadorP
Last active February 8, 2017 11:03
Show Gist options
  • Save SalvadorP/42370f493fc3d44aa1b4ada6c3bf59af to your computer and use it in GitHub Desktop.
Save SalvadorP/42370f493fc3d44aa1b4ada6c3bf59af to your computer and use it in GitHub Desktop.
Compress pdfs in batch, giving 2 types of qualities.
# Less compression nice results, links broken
ls | cat -n | while read n f; do ps2pdf "$f" "$f.comp2.pdf"; done
# A lot of compression jpg quality loss, respects links, changing PDFSettings can alter results more/less compression/quality
ls | cat -n | while read n f; do gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$f.comp.pdf" "$f"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment