从PostScript中提取位图 [英] Extract a bitmap from PostScript

查看:125
本文介绍了从PostScript中提取位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从PostScript文件(.ppf)中提取位图。它用RLE压缩并用ASCIIHexEncode编码。我会从PHP调用它。我想知道是否有一种优雅的方法。我不想重新发明wheel,但是我想使用现有的库。有没有办法从PostScript,Ghostscript或imagick调用压缩过滤器?

I need to extract a bitmap from a PostScript file (.ppf). It is compressed with RLE and encoded with ASCIIHexEncode. I will call it from PHP. I wonder if there is an elegant way to do that. I don't want to reinvent wheel, but I would like to use existing libraries. Is there a way how to call compression filters from PostScript, Ghostscript or imagick?

推荐答案

您可以编写PostScript程序以对输入运行压缩/解压缩过滤器。因此,如果您已经将位图数据提取到名为myfile.rle.hex的文件中,则可以将其放入文件中(例如,称为Decode.ps):

You can write a PostScript program to run compression/decompression filters on input. So, if you have the bitmap data already extracted in a file called myfile.rle.hex, you could put this in a file (eg called decode.ps) :

/InFile (/home/ken/myfile.rle.hex) (r) file /ASCIIHexDecode filter 
/RLEDecode filter 
def
/OutFile (/home/ken/myfile.raw) (w) file def
/Data 32768 string def

{
    InFile Data readstring {
    OutFile exch writestring
    } {
    OutFile exch writestring
    exit
    } ifelse
} loop

InFile closefile
OutFile closefile

然后 gs encode.ps。还有其他方法可以实现,您可以使用-c将全部内容放在Ghostscript命令行上,可以使用-c在命令行上定义文件名,然后运行解码.ps但替换为(/ home / ken / myfile.hex.rle)与您在命令行上定义的文件名。您可以使用其他过滤器在原始PostScript中查找数据。

Then "gs decode.ps". There are other ways to achieve this, you could put the whole lot on the Ghostscript command line using -c, you could define the file name on the command line with -c and then run decode.ps but replacing (/home/ken/myfile.hex.rle) with the filename you defined on the command line. You can use other filters to find the data in the original PostScript.

但是,在不了解更多有关如何查看输入和输出的情况下,我无法真正提出任何建议工作。

But I can't really suggest any of these without knowing more about how you see the input and output working.

这篇关于从PostScript中提取位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆