0

我正在尝试使用 ghostscript 扫描 PDF 并告诉我哪些页面是彩色的,哪些是黑白的。我编写了一个脚本,用 ghostscript 打印出每一页及其颜色。当我使用命令行运行此脚本时,我收到以下警告:

Page 56
**** Warning: Short look-up table in the Indexed color space was padded with 0's.

这似乎不是问题,因为脚本一直持续到它完成了所有剩余的 356 页。但是,当我使用 exec() 或 system() 函数在 PHP 中运行此脚本时,我在第 56 页得到以下信息:

Page 56 
Error: /ioerror in --run-- Operand stack: --dict:11/20(L)-- --dict:10/18(L)-- 3092695 
Indexed DeviceCMYK 56 
(\000\000\000\000\b\001\016\000\033\0040\000\005\001\t\000\002\000\003\000\)\007K\0008\bh\000N\017\224\000W\016\247\000r\034\327\000t\033\334\000\016\001\036\000D\t\177\000]\025\264\0003\007b\000S\021\234\000m\032\317\000\275t\007\000o9\t\000i\027\311\000;\to\000c\026\272\000,\006T\000\035\0047\000\022\002#\000\177jj\016uab\006r^_\005\f\t\t\000~ii\r\204oo\024SBC\000\005\003\003\000]KL\000o[\\\003\277\255\253\346\034\025\027\000@34\000\025\017\020\000gSU\001\275\254\252\335\265\245\243\255vac\007\271\252\247\312\221{z%\262\242\240\234%\034\035\0007+,\000\245\222\220X\212ut\033...) --nostringval-- 
Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1910 1 3 %oparray_pop 1909 1 3 %oparray_pop 1893 1 3 %oparray_pop --nostringval-- --nostringval-- 57 1 346 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- --nostringval-- %loop_continue --nostringval-- 3092695 --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- --nostringval-- 
Dictionary stack: --dict:1162/1684(ro)(G)-- --dict:1/20(G)-- --dict:82/200(L)-- --dict:82/200(L)-- --dict:108/127(ro)(G)-- --dict:291/300(ro)(G)-- --dict:23/30(L)-- --dict:6/8(L)-- --dict:27/40(L)-- --dict:1/1(ro)(G)-- --dict:1/1(ro)(G)-- --dict:5/16(L)-- 
Current allocation mode is local Last OS error: 9 Unrecoverable error: ioerror in quit 
Operand stack: --nostringval-- --nostringval-- 

在我收到此错误后,PHP 脚本将停止并且不会像我在命令行中运行程序时那样继续。为什么我只会在 PHP 中得到这个错误,我该如何纠正它以忽略这些警告/错误?

以下是我调用 ghostscript 时的标志:

gs -dNOPAUSE -dBATCH -dSAFER -sDEVICE=display -dDisplayHandle=0 
   -dDisplayFormat=(values for DISPLAY_COLORS_RGB|DISPLAY_DEPTH_8|DISPLAY_LITTLEENDIAN|DISPLAY_BOTTOMFIRST) 
   test.pdf -f

我也在使用ghostscript-9.05

4

1 回答 1

0

您确定您的 PHP 调用 Ghostscript 会找到与您的命令行完全相同的版本吗?

您是否有可能在 2 个不同的位置安装了 2 个不同的 Ghostscript 实例?

你应该跑

gs -v

gs -h

从 PHP 内部以及命令行查看它们是否相同。

于 2012-07-17T21:02:53.953 回答