How to normalize a scanned PDF with ImageMagick

Scanning documents isn’t one of those things I do on a regular basis and thus I don’t spend much time trying to calibrate the contrast of the document. And if you’re like me you often get scanned PDFs where anything that’s suppose to be black (print, black pen) appears grayish and washed out. Thankfully, I’ve found that there’s an easy (and free) way to fix scanned PDFs that turn out like that. All you need to fix this is a program called ImageMagick (which is also useful for many other image-based operations).

Installing ImageMagick

For Windows users:

  • Install the appropriate binaries from here
  • During installation make sure the box is checked for Add application directory to your system path
  • In order for ImageMagick to be able to handle PDFs you also need to download and install GhostScript from this link

For Linux (Ubuntu/Debian) users:

ImageMagick is included in the software repository so you just need to run the following commands to install it.

sudo apt-get update
sudo apt-get install imagemagick

Normalizing the PDF

Next open up a command prompt/terminal and navigate to where the PDF is that you want to normalize. Then just run the following command after replacing input.pdf with your original file and output.pdf with what you the new file to be called.

convert -density 150 -normalize -quality 100 input.pdf output.pdf

The one thing you may need to modify here is the density. To my understanding you want this to match the DPI resolution that you used when scanning your document. After everything is squared away and you’ve run the command, your PDF should now be normalized.