如何快速生成PDF所有页面的PNG缩略图?
我使用以下代码来执行此操作:
for i in `seq 1 $numPages`; do
convert "$INPUTPDF"[$((i-1))] thumb_$i.png
done;
它有点慢,我认为这是因为它每次都会启动一个新进程。
如何更快地做到这一点?
预先非常感谢!
I use a following code to do this:
for i in `seq 1 $numPages`; do
convert "$INPUTPDF"[$((i-1))] thumb_$i.png
done;
It's kinda slow, and I think it's because it starts a new process every time.
How to do this faster?
Thanks very much in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下是无耻地窃取:
这将解析您的pdf 只一次。呜呜。
根据此过程所需的时间,同时运行其中几个可能是有意义的。如果您拥有多核或 SMP 计算机,您可能会发现同时运行两个、三个甚至四个
convert(1)
进程的好处。简单的方法是将这样的命令放入两个或多个 shell 脚本中,然后并行运行这些 shell 脚本。您可以像这样生成这些脚本:不过,这已经是相当糟糕的了。如果您要经常这样做,我建议为
make(1)
编写一个Makefile
或您自己的小型进程管理器工具,以利用多个CPU。哎呀,也许类似的东西已经存在了。 :)The following was shamelessly stolen:
This will parse your pdf only once. Woot.
Depending upon how long this process takes, it might make sense to run several of these simultaneously. If you've got a multi-core or SMP machine, you might see benefit to running two, three, or maybe even four
convert(1)
processes at once. The easy way would be to place commands like this into two or more shell scripts, and then run the shell scripts in parallel. You could generate these scripts like this:This is pretty hacked-together though. If you're going to be doing this often, I'd suggest writing a
Makefile
formake(1)
or your own little process-manager tool to take advantage of multiple CPUs. Heck, maybe something like that already exists. :)