Use can use the convert
command to convert a PDF into images. It uses ImageMagick behind the scenes.
The following will convert foo.pdf
PDF into foo-[n].jpg
images, where [n]
is an image number from 0:
convert foo.pdf foo.jpg
Note that it will create an image per PDF page.
Example:
me@pc ~/test $ convert foo.pdf foo.jpg
me@pc ~/test $ ls -l foo*
-rw-r--r-- 1 steph steph 468902 Sep 5 15:09 foo-0.jpg
-rw-r--r-- 1 steph steph 589703 Sep 5 15:09 foo-1.jpg
-rw-r--r-- 1 steph steph 465899 Sep 5 15:09 foo-2.jpg
-rw-r--r-- 1 steph steph 565752 Sep 5 15:09 foo-3.jpg
-rw-r--r-- 1 steph steph 577887 Sep 5 15:09 foo-4.jpg
-rw-r--r-- 1 steph steph 243387 Sep 5 15:09 foo-5.jpg
-rw-r--r-- 1 steph steph 295983 Sep 5 15:09 foo-6.jpg
-rw-r--r-- 1 steph steph 237054 Sep 5 15:09 foo-7.jpg
-rw-r--r-- 1 steph steph 354295 Sep 5 15:09 foo-8.jpg
-rw-r--r-- 1 steph steph 271331 Sep 5 15:09 foo-9.jpg
-rw-r--r-- 1 steph steph 4152133 Sep 4 14:21 foo.pdf
Note how it created ten JPGs from the one PDF.
Quality
By default convert
will use ImageMagick’s default quality (aka density), which is 72 DPI.
To increase the quality you can bump up the density:
convert -density 300 foo.pdf bar.jpg
300 DPI is the max.
You could alternatively specify different units for the density (see ImageMagick: Command-line Options -units):
convert -density 20 -units PixelsPerCentimeter foo.pdf foo.jpg
Colour space
If you get a black background in your images, try changing the colour space:
convert -colorspace CMYK foo.pdf bar.jpg