【问题标题】:GraphicsMagick: Cannot convert pdf to jpegGraphicsMagick:无法将 pdf 转换为 jpeg
【发布时间】:2017-03-15 00:24:24
【问题描述】:

我正在尝试将 pdf 文档(95 页)转换为多个 JPEG 文件,但出现错误:

$gm convert -verbose -density 300 TESTIO.pdf +adjoin FOO-%02d.jpg
 [ghostscript library] "-q" "-dBATCH" "-dSAFER" "-dMaxBitmap=50000000" "-dNOPAUSE" "-sDEVICE=pnmraw" "-dTextAlphaBits=4" "-dGraphicsAlphaBits=4" "-r300x300" "-sOutputFile=/tmp/gm2BfrxJ" "--" "/tmp/gmWNsJU0" "-c" "quit"Error: /ioerror in --showpage--
 Operand stack:
    1   true
 Execution stack:
    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1862   1   3   %oparray_pop   1861   1   3   %oparray_pop   1845   1   3   %oparray_pop   --nostringval--   --nostringval--   24   1   95   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   1745   0   9   %oparray_pop   --nostringval--   --nostringval--
 Dictionary stack:
    --dict:1154/1684(ro)(G)--   --dict:1/20(G)--   --dict:76/200(L)--   --dict:76/200(L)--   --dict:106/127(ro)(G)--   --dict:286/300(ro)(G)--   --dict:22/25(L)--   --dict:4/6(L)--   --dict:22/40(L)--
 Current allocation mode is local
 Last OS error: 28
 GPL Ghostscript 8.70: Unrecoverable error, exit code 1
 gm convert: Unexpected end-of-file (/tmp/gm2BfrxJ). 

这是 GraphicsMagick 的配置:

$gm version
GraphicsMagick 1.3.25 2016-09-05 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2016 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.

Feature Support:
  Native Thread Safe       yes
  Large Files (> 32 bit)   yes
  Large Memory (> 32 bit)  yes
  BZIP                     no
  DPS                      no
  FlashPix                 no
  FreeType                 no
  Ghostscript (Library)    yes
  JBIG                     no
  JPEG-2000                no
  JPEG                     yes
  Little CMS               no
  Loadable Modules         no
  OpenMP                   yes (200805)
  PNG                      no
  TIFF                     yes
  TRIO                     no
  UMEM                     no
  WebP                     no
  WMF                      no
  X11                      no
  XML                      no
  ZLIB                     no

Host type: x86_64-unknown-linux-gnu

Configured using the command:
  ./configure  '--prefix=/usr/local' '--with-modules=yes' '--with-libtiff' '--with-jpeg' '--with-gslib'

Final Build Parameters:
  CC       = gcc -std=gnu99
  CFLAGS   = -fopenmp -g -O2 -Wall -pthread
  CPPFLAGS =
  CXX      = g++
  CXXFLAGS = -pthread
  LDFLAGS  =
  LIBS     = -ltiff -ljpeg -lgs -lm -lgomp -lpthread

还有:

$ gs -version
GPL Ghostscript 9.20 (2016-09-26)
Copyright (C) 2016 Artifex Software, Inc.  All rights reserved.

【问题讨论】:

  • 您的 /tmp 文件系统是否已满?

标签: pdf ghostscript graphicsmagick


【解决方案1】:

首先,您在 GraphicsMagick 中使用了 版本的 Ghostscript。我知道该版本已返回 9.20,但如果您查看您发布的错误日志,您会看到“GPL Ghostscript 8.70:不可恢复的错误,退出代码 1”。所以您的 GraphicsMagick 安装使用的是 8.70。

在我看来,这是因为所有输出文件都被发送到相同的文件名。开关-sOutputFile=/tmp/gm2BfrxJ 会将所有页面写入单个文件。如果您希望它们转到多个文件,那么您需要指定多个页面输出,例如-sOutputFile=/tmp/gm2BfrxJ-%d 或类似的。

我怀疑问题仅仅是 GraphicsMagick 没有设置为处理这样​​的多个页面文件。一次进行一页转换。或者让 Ghostscript 为您将页面呈现为 JPEG。

【讨论】:

  • 即使我安装了 Ghostscript 9.04,但是当我运行命令时似乎:gm convert -density 300x300 TESTIO.pdf -resample 25 -scene 1 +adjoin pdf_conversion_%d.JPEG,GraphicsMagick 仍在寻找对于 Ghostscript 8.7,我如何使用 GhostScript 9.04 编译 GraphicsMagick。我对 GraphicsMagick 的编译、制作、安装是: ./configure --prefix=/usr/local --with-modules=yes --with-tiff --with-jpeg --with-gslib, make , sudo make install
  • 我无法告诉您有关 GraphicsMagick 的任何信息,抱歉。我的怀疑是它使用了一个 Ghostscript 共享对象,甚至可能它发布了一个(这会很讨厌)。
猜你喜欢
  • 1970-01-01
  • 2021-01-01
  • 2015-09-05
  • 2012-10-07
  • 2011-05-16
  • 2015-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多