Skip to content

Ghostscript

Ghostscript is an interpreter for PostScript and Portable Document Format (PDF) files.

Ghostscript is available as a module on Apocrita.

Usage

To run the default version of Ghostscript, simply load the ghostscript module:

$ module load ghostscript
$ gs --help
Usage: gs [switches] [file1.ps file2.ps ...]
Most frequently used switches: (you can use # in place of =)
 -dNOPAUSE           no pause after page   | -q       `quiet', fewer messages
 -g<width>x<height>  page size in pixels   | -r<res>  pixels/inch resolution
 -sDEVICE=<devname>  select device         | -dBATCH  exit after last file
 -sOutputFile=<file> select output file: - for stdout, |command for pipe,

For full usage documentation, run gs --help.

Example job

Serial job

Here is an example job running running on 1 core and 1GB memory:

#!/bin/bash
#$ -cwd
#$ -j y
#$ -pe smp 1
#$ -l h_rt=1:0:0
#$ -l h_vmem=1G

module load ghostscript

# convert a figure to an image file
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -dGraphicsAlphaBits=4 \
   -sOutputFile=image.png figure.eps

# render the same image at 300 dpi
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=png16m -r300 \
   -sOutputFile=image_300.png figure.eps

# render a figure in greyscale
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pnggray -sOutputFile=figure.png figure.pdf

# rasterise a whole document
gs -dSAFER -dBATCH -dNOPAUSE -sDEVICE=pgmraw -r150 \
   -dTextAlphaBits=4 -sOutputFile='file-%00d.pgm' file.ps

References