bash 将多页 PDF 转换为单个图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21605262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 09:29:26  来源:igfitidea点击:

Convert multipage PDF to a single image

linuximagebashpdfimagemagick

提问by Luca Davanzo

I have to convert a multipage PDF document to a .png image.

我必须将多页 PDF 文档转换为 .png 图像。

I try with ImageMagick, but I cannot achieve final result:

我尝试使用 ImageMagick,但无法获得最终结果:

convert document.pdf document.png

or

或者

convert -adjoin document.pdf document.png

This command create N images .png (where N=num of page of document):

此命令创建 N 个图像 .png(其中 N=文档页数):

document0.png
document1.png
.... 
document(N-1).png

I need, if possible with a single command, to obtain a single image.

如果可能,我需要使用单个命令来获取单个图像。

回答by Luca Davanzo

Finally I find THEsolution:

最后,我找到解决方案:

convert in.pdf -append out%d.png

Thanks to this post.

感谢这篇文章

edit

编辑

As a plus, the opposite operation is:

作为一个加号,相反的操作是:

convert *.png output.pdf

or if you have foo1.png, foo2.png..fooN.png

或者如果你有 foo1.png, foo2.png..fooN.png

convert foo?.png output.pdf

Notice that does not work with foo01.png, foo02.png..foo0N.png

请注意,这不适用于 foo01.png、foo02.png..foo0N.png

回答by xb.

+appendwill put images side by side, i.e.horizontally instead of vertically (with -append)

+append将并排放置图像,水平放置而不是垂直放置(使用-append

convert in.pdf +append out%d.png