How to convert PDF’s to JPEG’s (and vice versa)

If you don’t have expensive PDF editing software, you can convert your PDF to a JPG and then edit/add text/graphics accordingly, then convert the image back to a PDF.

To convert a PDF to a Jpeg, you’ll need Imagemagick (sudo apt-get install imagemagick).

convert -quality 20 -interlace none -density 300 input.pdf output.jpg

The quality setting can be from 0 to 100 (100 being the best, but often a huge file), I have found 20 to be a good balance of size vs. quality. The interlace option helps with readability, and density specifies the dots per inch (for printing). For PDF’s with color images, you may find you need to add the option -colorspace RGB.

The default print resolution when using the convert program on PDF’s is 72 dots per inch, which is equivalent to one point per pixel. Computer screens are normally 72 or 96 dots per inch, while printers typically support 150, 300, 600, or 1200 dots per inch. To determine the resolution of your display, use a ruler to measure the width of your screen in inches, and divide by the number of horizontal pixels (1024 on a 1024×768 display). Generally, I prefer to maintain enough density to support a possible print job.

This does work the other way around, so the command below will work just fine:

convert -quality 20 -interlace none -density 300 input.jpg output.pdf

When convertnig PDF’s to Jpeg’s, each page will be it’s own numbered Jpeg. You can then convert multiple Jpeg’s back into a single PDF (the page order will depend on the filename sorted order, so be sure to number your files in the preferred order).

The command below will take a series of Jpeg’s and convert them into a single PDF:

convert -quality 20 -interlace none -density 300 *.jpg output.pdf