GhostScript命令从PDF文件创建缩略图图像

时间:2014-10-15 13:07:13

标签: pdf imagemagick jpeg thumbnails ghostscript

我正在尝试从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

2 个答案:

答案 0 :(得分:3)

下面的代码对我有用。

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

-dDEVICEWIDTHPOINTS =像素 -dDEVICEHEIGHTPOINTS =像素

答案 1 :(得分:1)

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

我假设轮换是你的问题。你说你不能将输出图像的大小调整为固定大小(250x250)&#34;但你继续说&#34;命令-dPDFFitPage = true使输出图像适合给定的维度&#34;很明显你可以调整输出大小。

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

相关问题