【问题标题】:GhostScript command create thumbnail images from PDF fileGhostScript 命令从 PDF 文件创建缩略图
【发布时间】:2014-12-10 13:56:13
【问题描述】:

我正在尝试从 PDF 文件创建缩略图。我可以从以下命令生成 JPEG 图像,但问题是我无法将输出图像的大小调整为固定大小(250x250)

命令 -dPDFFitPage=true 使输出图像适合给定尺寸,并且图像显示为旋转。谁能帮我解决这个问题,以生成 250x250 大小的 PDF 文件的缩略图。

/usr/bin/gs -dNOPAUSE -sDEVICE=jpeg -dFirstPage=1 -dLastPage=1 -sOutputFile=<path to output file>%d.jpeg -dJPEGQ=100 -g250x250 -dUseCropBox=true  -dPDFFitPage=true -q  <path to input file>.pdf -c quit

谢谢 萨钦

GhostScript 9.15 版本出错

根据建议,我已经安装了 Ghostscript 9.15 版本。但安装后,我通过的任何命令都会出错。如何纠正或检查 GS 9.15 是否已正确安装。

 **** Error reading a content stream. The page may be incomplete.
   **** File did not complete the page properly and may be damaged.
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   1945   1   3   %oparray_pop   1944   1   3   %oparray_pop   1928   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   1826   0   11   %oparray_pop   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1187/1684(ro)(G)--   --dict:1/20(G)--   --dict:82/200(L)--   --dict:82/200(L)--   --dict:116/127(ro)(G)--   --dict:280/300(ro)(G)--   --dict:30/32(L)--   --dict:6/8(L)--   --dict:21/40(L)--   --dict:1/1(ro)(G)--   --dict:7/17(L)--
Current allocation mode is local
Last OS error: No such file or directory
GPL Ghostscript 9.15: Unrecoverable error, exit code 1
Unrecoverable error: typecheck in setpagedevice

【问题讨论】:

    标签: pdf imagemagick jpeg thumbnails ghostscript


    【解决方案1】:

    下面的代码对我有用:

    gs -sDEVICE=jpeg -dPDFFitPage=true -dDEVICEWIDTHPOINTS=250 -dDEVICEHEIGHTPOINTS=250 -sOutputFile=outputfile.jpeg inputfile.pdf
    
    -dDEVICEWIDTHPOINTS=pixels
    -dDEVICEHEIGHTPOINTS=pixels
    

    【讨论】:

      【解决方案2】:

      我怀疑旋转是由于 PDF 更适合这种方式(涉及较少缩放),但我需要查看 PDF 文件的示例来说明。

      我假设轮换是您的问题。您说您“无法将输出图像的大小调整为固定大小( 250x250 )”,但您继续说“命令 -dPDFFitPage=true 正在使输出图像适合给定尺寸”所以显然您能够调整输出大小。

      您还应该说明您使用的是哪个版本的 Ghostscript,如果您没有使用最新版本 (9.15),您应该尝试一下。

      【讨论】:

      • 我使用的是 GhostScript 9.10 版本。我的实际问题是进行所需的缩放。使用 -g250x250 我得到了所需的 250x250 尺寸,但图像更适合垂直方式。我的要求是以缩略图(250x250)大小创建输入 PDF 文件的 JPEG 图像。
      • 第一个建议是'使用当前版本,9.15'。我不认为缩放是你的问题,因为你说你得到了正确的大小,听起来你的问题仍然是旋转。但是如果没有看到一个例子就很难说。我建议您在公共地方放置一个(小)示例并将 URL 放在这里。
      • 我也尝试过使用不同组合的以下命令,但到目前为止没有运气 -dFIXEDMEDIA -dDEVICEWIDTHPOINTS=250 -dDEVICEHEIGHTPOINTS=250 -dDEVICEWIDTH=250 -dDEVICEHEIGHT=250
      • 这些都适用于调整媒体大小,如果您选择 -dPDFFitPage,内容将被缩放到输出。您可以尝试当前版本或在公共地方发布示例文件,以便人们查看。没有它,它真的不可能进一步评论。我确实知道这通常有效。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-20
      • 1970-01-01
      • 2016-05-10
      • 1970-01-01
      • 1970-01-01
      • 2013-07-25
      • 1970-01-01
      相关资源
      最近更新 更多