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
#SBATCH -n 1 # (or --ntasks=1) Request 1 core
#SBATCH --mem-per-cpu=1G # Request 1GB RAM per core
#SBATCH -t 1:0:0 # Request 1 hour runtime
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