How to Convert PDFs to Image Files with ImageMagick in macOS

To convert PDFs to image files, you’ll need to install Homebrew, ImageMagick, and Ghostscript. Homebrew is a package manager for macOS that allows you to install and manage a variety of software packages with a single command. ImageMagick can be thought of as the Swiss army knife of image processing and manipulation. Ghostscript is a PDF interpreter that’s required for ImageMagick to process PDF files.

Install Homebrew, ImageMagick, and Ghostscript

First, install Homebrew by pasting the command below into a Terminal prompt.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Next, install ImageMagick with this command.

brew install imagemagick

Finally, install Ghostscript with this command.

brew install ghostscript

Converting PDFs to Image Files with ImageMagick

To convert a PDF to individual PNG files, use the command below. ImageMagick supports a variety of image formats, so you can also use JPG, GIF, TIFF, and more for extension of the target image file.

convert file.pdf file.png

You can also specify input and output directories. The first command below creates a folder named *output* on my desktop. The second command takes file.pdf on my desktop and converts it to individual GIF files that are saved in the *output* directory. This is organizationally useful for PDFs with many pages.

mkdir ~/Desktop/output
convert ~/Desktop/file.pdf ~/Desktop/output/file.gif

If your converted images come out blurry, play around with the -density argument which specifies the PPI of the image file.

convert -density 300 file.pdf file.png

A Conversion Example

I ran the following command on my computer.

mkdir ~/Desktop/output
convert -density 300 ~/Desktop/file.pdf ~/Desktop/output/file.png

As you can see, ImageMagick converted the PDF into three PNG files.

That’s it. ImageMagick is a great customizable tool for converting PDF files to individual image files with a single command.

In Apps
#ImageMagick