Manually writing a basic PostScript script

I wanted to try and manually encode a PostScript file. What for? Why not. From Wikipedia, I copied and pasted my main Hello World program for PostScript , which:

 %!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 

When I try to open it in GIMP , I get

Error opening Hello World.ps. Failed to interpret file "Hello World.ps"

I can use ImageMagick to convert a file

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

PDF opens successfully and displays "Hello World" in Courier. EPS gives the same error as PS.

  • Is there something wrong with the syntax of the PS file?

  • PS files are simply not intended for direct viewing and should they be searched in a format such as PDF?

  • Is GIMP simply unable to handle this particular PS file format?

+5
source share
1 answer

To answer your questions, one by one:

  • The PostScript file is completely fine.

  • PostScript files can be viewed directly if you are using a PostScript compatible viewer. (BTW: PDF can be thought of as a "container format" - but it never embeds a PostScript file for "viewing" ...)

  • For Gimp to process PS / EPS files, you need a working Ghostscript ( installation link ) on your system.

Same as "3." true for your convert command: ImageMagick cannot process PS / EPS or PDF input files if there is no Ghostscript functional installation on the local system. This will work as the so-called β€œdelegate” used by ImageMagick to handle file formats that it cannot handle itself. The delegate converts this format into a raster file, which, in turn, ImageMagick can take over for further processing.

To check for available ImageMagick delegates, run the following commands:

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

Source: https://habr.com/ru/post/1212842/


All Articles