gpt4 book ai didi

ghostscript - 将光栅文件转换为 postscript 文件时出错

转载 作者:行者123 更新时间:2023-12-02 01:25:00 27 4
gpt4 key购买 nike

我正在尝试将 PWG 光栅文件数据转换为 postscript 数据。我在测试文件中生成如下:

%!PS-Adobe-3.0
%%BoundingBox: 0 0 5100 6600
%Creator: Cups-Filters
%LanguageLevel: 2
%DocumentData: Clean7Bit
%EndComments
%BeginProlog
%EndProlog

%Pages: (atend)
%%Page: 1 1
%%BeginPageSetup
<< /PageSize[5100 6600]/ImagingBBox null>> setpagedevice
%%EndPageSetup
gsave
gsave
5100 6600 scale
5100 6600 8 [5100 0 0 -6600 0 6600]
{currentfile 3 5100 string readhexstring pop} bind
false 3 colorimage

...hexadecimal information cut...

grestore
showpage
%PageTrailer
%Trailer
%%Pages: 1
%EOF

每当我尝试使用 GhostScript 解释器运行程序时,我都会收到以下错误:

$ ghostscript sample.ps 
GPL Ghostscript 9.18 (2015-10-05)
Copyright (C) 2015 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /typecheck in --colorimage--
Operand stack:
--nostringval-- 3 (\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000...)
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1977 1 3 %oparray_pop 1976 1 3 %oparray_pop 1960 1 3 %oparray_pop 1852 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- 1878 7 3 %oparray_pop
Dictionary stack:
--dict:1194/1684(ro)(G)-- --dict:0/20(G)-- --dict:78/200(L)--
Current allocation mode is local
Current file position is 399
GPL Ghostscript 9.18: Unrecoverable error, exit code 1

PS 文件大约 128 MB,其中大约 99% 的数据是彩色图像的十六进制表示。

我尝试搜索它,一位消息人士建议将“setpagedevice”参数添加到 PS 文件。我添加了它但没有效果。

我怎样才能摆脱这个错误?另外,还有其他方法可以在后记中表示非常大的图像吗?

最佳答案

您的代码包含:

{currentfile 3 5100 string readhexstring pop} bind

如果我们将其分解并添加关于我们得到的堆栈内容的评论:

{
currentfile % Stack contents: -file-
3 % stack contents: -file- 3
5100 % stack contents: -file- 3 5100
string % string consumes the top operand, creates a string
% object of that size, and places the string on the stack
% stack contains: -file- 3 (string)
readhexstring % consume string and file operands, return substring, bool
%
pop % pop the boolean
}

问题是 readhexstring 期望看到 -file-(字符串),但堆栈实际上 包含 3(字符串),3 不是文件对象,因此您会收到类型检查错误。

关于ghostscript - 将光栅文件转换为 postscript 文件时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37693967/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com