Saving Images to Files

Dynagraph images can be saved into files in a variety of graphics formats. Currently the following formats are are available: JPEG, TIFF, PNG, PPM (raw/binary and ASCII), POSTSCRIPT (grayscale and color rasterized formats) and POSTSCRIPT (color vector format).

With the exception of Postscript vector format, graphs are saved as raster images of screen pixels. Raster images are simple and compact, however they are not best suited for resizing or printing on high-resolution printers. The Postscript vector format saves the drawing instructions, not pixels, therefore it can reproduce the image scaled to arbitrary sizes and resolutions. Beware, however, that the Postscript vector files generated by dynagraph can be quite large and may take hours to print on a printer.

Images can be saved either through the command line or through the dynagraph's graphics display's File menu.

Dynagraph does not save images in the GIF format. See the section Why no GIF below.

Saving an image via a menu selection

An image saved via the File->Save menu is written into a file named dgplot.* in the current directory, where the .* extension is set to reflect the format of the saved image according to:

Format Extension
JPEG .jpg
TIFF .tiff
PNG .png
PPM (both binary and ascii) .ppm
Postscript (all formats) .ps

Remark: The file name dgplot is built in and cannot be changed when saving via a menu. See the description of the savegraph command below if you wish to specify a file name.

Saving an image via the savegraph() command

The savegraph() command can be invoked in two different ways:

    savegraph(format);
    savegraph(format, filename);

The format argument specifies the format of the saved image. Select it according to the following table:

Desired format  The format argument
JPEG jpg or jpeg
TIFF tiff
PNG png
PPM (binary) ppm or ppm-binary or ppm-raw or ppm6
PPM (ascii) ppm-ascii or ppm3
Postscript (grayscale) ps or postscript or postscript-gray
Postscript (color) cps or postscript-color or postscript-colour
Postscript (vector) vps or postscript-vector

If savegraph() is invoked with one argument, the currently displayed graph is saved in a dgplot.* file, This is equivalent to saving the image via the File->Save menu.

If savegraph() is invoked with two arguments, the second argument is taken to be the name of the file to save the image in. The user is responsible for providing an appropriate filename, e.g., mygraph.jpg; dynagraph will not append a .jpg or any other extension on its own. As always, file names which involve other than alphanumeric characters must be quoted. See the section Quoted Strings for details.

The savegraph() command can be called from dynagraph scripts when executing dynagraph in the non-interactive mode. See Dynagraph Scripts for the description of the non-interactive mode.

Why no GIF?

Support for the GIF image format is not included in dynagraph due to a controversial patent issue; see http://www.gnu.org/philosophy/gif.html for a description of the problem. It is recommended that the PNG format be used as a substitute for GIF, whenever possible. If pressed, you may save the graph in the binary PPM format, then use one of the many publicly available programs to convert it to GIF. Two such programs are:
Back to table of contents