i want to learn how many pages will be converted with ImageMagick command.
我想学习使用ImageMagick命令转换多少页面。
convert -density 150 -quality 100 -resize 800x "new.pdf" "pdtoimg.jpg"
It returns 6 pages with name of pdtoimg-0.jpg
to pdtoimg-5.jpg
.
它将pdtoimg-0.jpg的6页返回到pdtoimg-5.jpg。
is there any way to learn how many pages are in a pdf, or can I make it write the converted page names to an array?
有什么方法可以了解pdf中有多少页面,还是可以让它将转换后的页面名称写入数组?
If I want to take folder size, I have to wait all processing has ended.
如果我想拿文件夹大小,我必须等待所有处理已经结束。
1 个解决方案
#1
3
You could use identify
. This is also one of the ImageMagick commands.
你可以使用识别。这也是ImageMagick命令之一。
identify file.pdf
identify -format "%f: %n\n" file.pdf
But for PDFs, this can be quite slow (because ImageMagick needs to use Ghostscript as a delegate for PDF processing, and Ghostscript needs to do a complete interpretation of the PDF before IM will be able to spit out the info you are interested in).
但是对于PDF来说,这可能会非常慢(因为ImageMagick需要使用Ghostscript作为PDF处理的委托,并且Ghostscript需要在IM能够吐出您感兴趣的信息之前对PDF进行完整的解释)。
So much faster would be to use an external tool, which does not read in the complete PDF, but only evaluates its metadata object:
如此快得多的是使用外部工具,它不会读取完整的PDF,但只评估其元数据对象:
pdfinfo file.pdf
pdfinfo file.pdf | grep Pages:
pdfinfo file.pdf | grep Pages: | awk '{print $2}'
pdfinfo
is a tool available as part of the XPDF package or as part of the Poppler utilities (both available for Linux, Mac OS X and Windows).
pdfinfo是一个工具,可作为XPDF包的一部分或作为Poppler实用程序的一部分(可用于Linux,Mac OS X和Windows)。
#1
3
You could use identify
. This is also one of the ImageMagick commands.
你可以使用识别。这也是ImageMagick命令之一。
identify file.pdf
identify -format "%f: %n\n" file.pdf
But for PDFs, this can be quite slow (because ImageMagick needs to use Ghostscript as a delegate for PDF processing, and Ghostscript needs to do a complete interpretation of the PDF before IM will be able to spit out the info you are interested in).
但是对于PDF来说,这可能会非常慢(因为ImageMagick需要使用Ghostscript作为PDF处理的委托,并且Ghostscript需要在IM能够吐出您感兴趣的信息之前对PDF进行完整的解释)。
So much faster would be to use an external tool, which does not read in the complete PDF, but only evaluates its metadata object:
如此快得多的是使用外部工具,它不会读取完整的PDF,但只评估其元数据对象:
pdfinfo file.pdf
pdfinfo file.pdf | grep Pages:
pdfinfo file.pdf | grep Pages: | awk '{print $2}'
pdfinfo
is a tool available as part of the XPDF package or as part of the Poppler utilities (both available for Linux, Mac OS X and Windows).
pdfinfo是一个工具,可作为XPDF包的一部分或作为Poppler实用程序的一部分(可用于Linux,Mac OS X和Windows)。