Converting a multi page pdf to multiple pages using a single command

I want to convert multi page pdfs into single page images efficiently.

I already know how to do this one page at a time with imagemagick. For example,

convert x.pdf[2] x3.jpg

will give me the 3rd page of the pdf as an image. So if I figure out how many pages are in the pdf using identify then I can loop through and convert all pages in the pdf to images. This method can however take a while. For example a 15 page pdf could take anywhere between 15-30 seconds.

According to answers that I have seen elsewhere (also on the imagemagick forums) the following imagemagick command should split a pdf into multiple images.

convert x.pdf x-%0d.jpg

but all this ends up doing is creating the first page named x-0.jpg

As an alternative I have tried using pdftk with the burst capability. The problem I faced there is that burst does not work in all cases. It does for some pdf's and does not for some others.

Any suggestions on how to improve things would help.

My OS is Mac OSX Lion but I do need this working on CentOS 6 as well.

Answers


You're missing the quantity of digits. Use:

convert x.pdf x-%04d.jpg

Where 4 means 4 digits will be show on the page count.


If you use Graphicsmagick on Debian or ImageMagick on macOS you probably have to add ADJOIN to your command. So it should look like

convert x.pdf +adjoin x-%04d.jpg

Ran into the same issue. Reinstall Imagemagick to work in Mountain Lion. If you use brew the simply

  $brew unlink imagemagick
  $brew install imagemagick

Need Your Help

DOM event precedence

javascript javascript-events event-handling dom-events eventqueue

What order of precedence are events handled in JavaScript?

Can't install Silverlight Developer runtime

visual-studio-2010 visual-studio silverlight silverlight-5.0

I have installed VS 2010 professional with full installation in Windows 7.