PDF downsampling

Researching implies producing lots of PDF’s. Sometimes these PDF’s are exported without much control and become several MB large, which is inconvenient to send out to some else (e-mail) or even to the cloud or a printer. To deal with this issue, a common solution is to down sample the images in your PDF to a lower DPI value (reducing the number of pixels per square inch). If the target of the document is a handout paper (A4 or Letter size), 300 dpi is usually enough. But you might want to go even lower if the purpose is only screen-reading (150 or 150 dpi).

The industry standard software to fulfil this task is Adobe Acrobat or Adobe Distiller, but there are free options. One of those is using Ghostscript, a free set of tools widely used in the scientific community. After you install, run this command in OS X  Terminal, replacing “input.pdf” with your own target file. Remember that drag ‘n dropping a file into the terminal will immediately write its path. The output will be in your home folder under the name “downsampled.pdf” with 72dpi resolution (change these as needed).

gs \
  -o downsampled.pdf \
  -sDEVICE=pdfwrite \
  -dDownsampleColorImages=true \
  -dDownsampleGrayImages=true \
  -dDownsampleMonoImages=true \
  -dColorImageResolution=72 \
  -dGrayImageResolution=72 \
  -dMonoImageResolution=72 \
  -dColorImageDownsampleThreshold=1.0 \
  -dGrayImageDownsampleThreshold=1.0 \
  -dMonoImageDownsampleThreshold=1.0 \
   input.pdf

This code was borrowed from Kurt Pfeife.


[EDIT]

While trying to downsample on a new MacOS installation, I found that Ghostscript is not installed. As such I provide here what worked for me to get it installed, as seen in an Apple Discussion:

brew update
brew upgrade
brew install ghostscript
brew cleanup


All content © Copyright 2024 by Pedro de Azambuja Varela.
Subscribe to RSS Feed