Convert PDF to Images

Jun 18, 2011·
Julio Batista Silva
Julio Batista Silva
· 2 min read
blog iPhone

When I wanted to read a PDF on my old cell phone, I always had to convert the files to images. The same commands I used back then also proved useful for converting scanned book PDFs into lighter images and creating a new PDF to read on the iPhone.

Here I show how to do the conversion in 4 different ways. I prefer using imagemagick.

PDF to Image

Imagemagick

Install imagemagick.

julio@julio-acer ~> convert document.pdf image.jpg

High definition: convert -density 400 file.pdf -scale 2000x1000 hi-res%03d.jpg

For iPhone: convert book.pdf -density 72 -quality 75 -scale 640x960 -colors 96 book%03d.jpg

For each page, it generates an image and names it as book001.jpg, book002, and so on.

PPM

Install pdftoppm and ppmtojpeg.

ppm document.pdf image.ppm

You can use -f start_page -l end_page to convert only a range.

PPM = portable pixmap file format

To convert, we use:

for file in *.ppm; do ppmtojpeg $file > ${file/.ppm/.jpg}; rm $file; done

Ghostscript

gs -sDEVICE=jpeg -sOutputFile=image.jpg document.pdf

Gimp

The best result I achieved for the old cell phone was to open the PDF as images in Gimp and save as .bmp. I need to figure out how to automate this process.

Image to PDF

convert *jpg book.pdf

If the file becomes too large, try using the -compress option

convert -compress jpeg *jpg book.pdf

Julio Batista Silva
Authors
Senior Cloud Developer

I’m a Brazilian computer engineer based in Germany, passionate about tech, science, photography, and languages.

I’ve been programming for about two decades already, exploring everything from mobile apps and web development to machine learning. These days I focus on cloud SRE and data engineering.

I volunteer in the open source and Python communities, helping organize PyCon DE and PyData Berlin, mentoring, and contributing with code and translations.

On my blog, I share Linux tips, setup guides, and personal notes I’ve written for future reference. I hope others find them helpful as well. The content is available in multiple languages.

Browse my gallery for some of my photography.

Away from the keyboard, you’ll find me at concerts, playing clarinet, cycling, scuba diving, or exploring new places, cultures, and cuisines.

Always happy to connect! 🙂

comments powered by Disqus