Convert PDFs Into Images Using Terminal Commands
When I am working on a website, I often need an image version of the first page of a PDF file to use as a thumbnail image. To save time (and to feel like a real-life wizard), I found a way to convert PDF files using Terminal commands. This should work using your command line (Terminal) on your Mac. An intro into using Terminal can be found in my post about resizing images using Terminal.
Here is How to Convert The First Page of a PDF Into an Image using Terminal
Convert the First Page of a PDF Into a PNG
sips -s format png example.pdf --out example.png
You can also convert this page into a JPG:
sips -s format jpeg example.pdf --out example.jpg
These terminal commands rely on a tool called sips which is included in Mac OS X.
Convert PDF Files Into Images in Bulk
This command can also be run to convert the first page of a whole bunch of PDFs in a directory in bulk. Here are a few examples on how this can work. In these examples, the file name of the image will be the same as the original PDF file name.
PNG Example:
sips -s format png *.pdf --out .
JPEG Example
sips -s format jpeg *.jpg --out .
Limitations
A major limitation of these commands is that only the first page of the PDF is converted into an image. This works great for creating a thumbnail graphic, but it would not work if all pages are needed. If anyone has found a method for converting all pages into a PDF, let me know on Twitter @themarcbacon.