ImageMagick-抑制警告消息

ImageMagick-抑制警告消息,imagemagick,cmd,Imagemagick,Cmd,我使用以下内容获取PDF文档中的总页数: identify -format %n test.pdf 然后我去掉所有非数字字符,从响应中得到一个整数 **** Warning: Fonts with Subtype = /TrueType should be embedded. The following fonts were not embedded: Arial Arial,Bol

我使用以下内容获取PDF文档中的总页数:

identify -format %n test.pdf
然后我去掉所有非数字字符,从响应中得到一个整数

   **** Warning: Fonts with Subtype = /TrueType should be embedded.
             The following fonts were not embedded:
                    Arial
                    Arial,Bold
                    Arial,Italic
                    Times New Roman

    **** This file had errors that were repaired or ignored.
    **** The file was produced by:
    **** >>>> Microsoft« Office Word 2007 <<<<
    **** Please notify the author of the software that produced this
    **** file that it does not conform to Adobe's published PDF
    **** specification.

    9
偶尔会产生以下错误,这会导致上面产生不正确的页数,因为它们是与响应中的页数无关的其他数字

   **** Warning: Fonts with Subtype = /TrueType should be embedded.
             The following fonts were not embedded:
                    Arial
                    Arial,Bold
                    Arial,Italic
                    Times New Roman

    **** This file had errors that were repaired or ignored.
    **** The file was produced by:
    **** >>>> Microsoft« Office Word 2007 <<<<
    **** Please notify the author of the software that produced this
    **** file that it does not conform to Adobe's published PDF
    **** specification.

    9
****警告:应嵌入子类型为/TrueType的字体。
未嵌入以下字体:
Arial
Arial,粗体
Arial,斜体
新罗马时代
****此文件存在已修复或忽略的错误。
****该文件由以下人员生成:

****>>>>Microsoft«Office Word 2007警告将转到stderr,因此简单的输出重定向将实现以下目的:

 identify -format %n test.pdf 2>/dev/null

警告将发送到stderr,因此一个简单的输出重定向将实现以下目的:

 identify -format %n test.pdf 2>/dev/null

从identify的手册页:

-安静抑制所有警告消息

因此,为了抑制警告消息,您的命令应如下所示:

identify -quiet -format %n test.pdf

从identify的手册页:

-安静抑制所有警告消息

因此,为了抑制警告消息,您的命令应如下所示:

identify -quiet -format %n test.pdf

我通过断行分解响应并仅使用包含页数的最后一个来解决此问题。警告可能不是Imagemagick警告,但可能来自Ghostscript。我通过断行分解响应并仅使用包含页数的最后一个来解决此问题。警告可能不是一个Imagemagick,但可能来自Ghostscript。