手写基本的 PostScript 脚本

Writing a basic PostScript script by hand

我想尝试手动编写 PostScript 文件。为什么?为什么不。我从维基百科复制并粘贴了 PostScript 的基本 Hello World 程序,即:

%!PS
/Courier             % name the desired font
20 selectfont        % choose the size in points and establish 
                     % the font as the current one
72 500 moveto        % position the current point at 
                     % coordinates 72, 500 (the origin is at the 
                     % lower-left corner of the page)
(Hello world!) show  % stroke the text in parentheses
showpage             % print all on the page

当我尝试在 GIMP 中打开它时,我得到

Opening 'Hello World.ps' failed. Could not interpret file 'Hello World.ps'

我可以使用ImageMagick转换文件

convert "Hello World.ps" "Hello World.pdf"
convert "Hello World.ps" "Hello World.eps"

PDF打开成功,并在Courier中显示'Hello World'。 EPS 产生与 PS.

相同的错误

为您一一解答:

  1. 你的PostScript文件是完全OK的。

  2. 如果您使用支持 PostScript 的查看器,则可以直接查看 PostScript 文件。 (顺便说一句:PDF 可能被视为 'container format'——但它从不为 'viewing' 嵌入 PostScript 文件...)

  3. 要让 Gimp 能够处理 PS/EPS 文件,您的系统上需要一个正常工作的 Ghostscript (installation link)。

同“3”点。对于您的 convert 命令是正确的:ImageMagick 无法处理 PS/EPS 或 PDF 输入文件,除非在本地系统上安装了可用的功能性 Ghostscript。这将作为所谓的 'delegate' 工作,ImageMagick 使用它来处理它自己无法处理的文件格式。委托将这种格式转换为光栅文件,然后 ImageMagick 可以接管该文件以进行进一步处理。

要检查可用的 ImageMagick 委托,运行 这些命令:

convert -list delegate

convert -list delegate | grep -Ei --color '(eps|ps|pdf)'