Skip to content

Instantly share code, notes, and snippets.

@williamrowell
Created January 30, 2022 04:20
Show Gist options
  • Save williamrowell/f9980b30bbd0779fa035d2f2b3245d21 to your computer and use it in GitHub Desktop.
Save williamrowell/f9980b30bbd0779fa035d2f2b3245d21 to your computer and use it in GitHub Desktop.
reduceMPL
#!/usr/bin/env bash
# from https://leancrew.com/all-this/2022/01/reducing-the-size-of-large-pdfs/
# Reduces the size of PDF plots created by Matplotlib.
# Assumes that the files to be reduced are named mpl[Something].pdf
# and that it's called via
#
# reduceMPL mpl*.pdf
#
# The results are a set of smaller files named [Something].pdf
# The original files are *not* deleted.
for mpl do
new=$(cut -c 4- <<< "$mpl")
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile="$new" "$mpl"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment