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

筅森魡賤 提交于 2019-12-18 11:42:19

问题


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.


回答1:


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.




回答2:


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



回答3:


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

  $brew unlink imagemagick
  $brew install imagemagick


来源:https://stackoverflow.com/questions/17025515/converting-a-multi-page-pdf-to-multiple-pages-using-a-single-command

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!