chiliNUT
chiliNUT

Reputation: 19573

Writing a basic PostScript script by hand

I wanted to try and manually code a PostScript file. Why? Why not. From Wikipedia, I copied and pasted their basic Hello World program for PostScript which is:

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

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

I can use ImageMagick to convert the file

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

The PDF opens successfully and displays 'Hello World' in Courier. The EPS yields the same error as the PS.

Upvotes: 5

Views: 2528

Answers (1)

Kurt Pfeifle
Kurt Pfeifle

Reputation: 90213

To answer your questions, one by one:

  1. You PostScript file is completely OK.

  2. PostScript files can be viewed directly if you use a PostScript-capable viewer. (BTW: PDF may be regarded as a 'container format' -- but it never embeds a PostScript file for 'viewing'...)

  3. For Gimp to be able and handle PS/EPS files, you need a working Ghostscript (installation link) on your system.

The same as point '3.' is true for your convert command: ImageMagick cannot handle PS/EPS or PDF input files unless there is a functional Ghostscript installation available on the local system. This would work as a so-called 'delegate', employed by ImageMagick to handle file formats which it cannot handle itself. A delegate converts such a format into a raster file, which ImageMagick in turn can then take over for further processing.

To check for available ImageMagick delegates, run these commands:

convert -list delegate

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

Upvotes: 7

Related Questions