SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Vol 2

GD

Name:
    GD
Type:
    Output Device Command
Purpose:
    Create PNG, JPEG, or GIF format graphics files.
Description:
    PNG, JPEG and GIF format graphics files are useful for web applications since most web browsers provide native support for these formats (i.e., the graphs can be viewed using the an <img> tag without the use of a plug-in). These formats can also be useful for importing graphs into word processing and presentation programs since many of these program can import these type of files directly. In addition, if you need a graphic in a specific image format, many image conversion programs can convert these formats into a wide variety of other image formats.

    GIF is still probably the most popular format for web applications. GIF was not supported in earlier versions due to a patent issue. The patent is no longer being enforced, so GIF support was included starting in 3/2006.

    JPEG is primarily intended for photographic type images, although it can be used for basic plotting images as well.

    PNG was developed as a free and non-patented alternative to GIF. It is the primary image format for a number of popular software programs (for example, Perl).

    Although GIF, JPEG, and PNG images can be created from Dataplot Postscript files using one of the numerous image conversion programs now available, it is still convenient to be able to generate these files directly from Dataplot. This can be done using the GD device driver. Note that Postscript files may still be of interest for some applications due to the fact that the Postscript graphs are rendered with greater resolution.

    Dataplot uses the GD library, originally developed by Thomas Boutell, to generate GIF, PNG and JPEG files. This is the library used by Perl (and many other programs) to generate GIF, PNG, and JPEG images. GD in turn uses four additional libraries: zlib, libpng, libjpeg, and libfreetype. These libraries are all freely downloadable from the web. If these libraries are not currently installed on your system, the URL's and current versions (as of 10/2014) are as follows:

    Dataplot is not particularly sensitive to which version of the GD library you have on your system. Any reasonably current version should suffice. The major restriction is that GD 1.x versions are no longer supported (GD changed some calling sequences in moving to the 2.x versions. The Dataplot code is now updated to use the 2.x calling sequence This change was made in the 3/2006 version of Dataplot).

    The availability of the GD device driver in Dataplot is dependent on having these libraries built on the given platform. The pre-built Dataplot executables for Linux, Cygwin, and Mac OS X should support this capability. The GD library is not currently supported for the Microsoft Windows executables.

    Note: Dataplot upgraded to use the 2.1 version of GD July, 2014 (this is the version that is now being maintained by the PHP organization). With this upgrade, Dataplot now supports several additional image formats.

    1. added support for the BMP format. This device was available in previous versions of GD, but I had not activated it for Dataplot. BMP is a common format in the Windows environment.

    2. added support for the WBPM format. This device was available in previous versions of GD, but I had not activated it for Dataplot. WBMP is a black and white format that was originally intended for mobile/wireless applications. It is not commonly used anymore.

    3. added support for TGA (Targa format).

    4. added support for TIFF. Note that this option requires that the "LIBTIFF" library be installed, so this format may not be available in some Dataplot installations.

    5. the webp format is supported if the VPX library is available. This is a relatively new format championed by Google. It is primarily intended for viewing videos on the web. This format will probably not be available on most Dataplot installations.
Syntax 1:
    GD <format>
    where <format> is one of PNG, JPEG, GIF, BMP, WBMP, TIFF, TARGA, or WEBP.

    This form designates device 1 as an GD graphics device.

Syntax 2:
    DEVICE <1/2/3> GD <format>
    where <format> is one of PNG, JPEG, GIF, BMP, WBMP, TIFF, TARGA, or WEBP.

    This form designates one of DATAPLOT's 3 devices (typically device 2) as an GD device.

Examples:
    DEVICE 2 GD PNG
    DEVICE 2 GD JPEG
Note:
    DATAPLOT must be linked with the proper GD libraries in order for the GD driver to work. If this is not the case, contact your local DATAPLOT installer.
Note:
    Typically, for PNG, JPEG, or GIF output, it is desirable to put each plot in a separate file with a unique name. This can be accomplished with a sequence of commands like the following:

      SET IPL1NA PLOT1.PNG
      DEVICE 2 GD PNG
      generate first plot
      DEVICE 2 CLOSE
      SET IPL1NA PLOT2.PNG
      DEVICE 2 GD PNG
      generate second plot
      DEVICE 2 CLOSE

    The SET IPL1NA command specifies the name of the file. Note that this name is currently converted to upper case. This command should come before the DEVICE 2 GD command.

Note:
    The default image size is 600 pixels by 450 pixels. You can change the default size of the image by using the DEVICE ... PICTURE POINTS command. For example,

      SET IPL1NA PLOT1.PNG
      DEVICE 2 GD PNG
      DEVICE 2 PICTURE POINTS 300 300
      generate first plot
      DEVICE 2 CLOSE
Note:
    An alternative method for generating JPEG files using either Ghostscript or the ImageMagick convert programs is now available for Windows and Unix/Linux platforms. For details, enter

    Under Windows, an alternative is to use Ghostview to convert postscript files to JPEG or PNG. Once you import the Dataplot postscript graph into Ghostview, select "File" and then select "Convert". This menu will then let you select the image type and the resolution (we suggest using 300 dpi since this is the default resolution Dataplot uses for Postscript graphs). This is preferred method under Windows since it allows you to preserve the high quality fonts and 300 dpi resolution of the original Postscript graph while providing a graphics format that can be easily handled by most Windows applications. The one drawback is that it doesn't work if you need a fully automated process.

Note:
    GD supports hardware text in the following two ways:

    1. There are 5 built-in fonts: TINY, SMALL, MEDIUM, LARGE, or GIANT. These will be available on platform where you have the GD library installed.

    2. If you have True Type fonts installed on your system, you can specify that Dataplot use these fonts. There are both commercial and freely downloadable true type fonts available. Note that Dataplot does not, and will not, provide any of these fonts. You are responsible for knowing if you have any true type fonts installed on your system and where these fonts are installed if you do have them. We will not provide any guidance on where to find these fonts.

    In either case, you can specify the font to use with the command (there is no default font)

      SET GD FONT <font name>

    GD renders fonts using the Free Type library.

    This capability was added to Dataplot 3/2008. Versions prior to this rendered text using one of Dataplot's software fonts.

Note:
    There are two color models supported. The "fixed" mode uses a color palette with a maximum of 256 colors. The "true" mode supports RGB mode where each of the three components can be set from 0 to 255.

    To specify the color model, enter

      SET GD COLOR <TRUE/FIXED>

    The default is FIXED. The TRUE mode is recommended if you are going to be generating image plots.

Note:
    Dataplot also uses the GD library to read image data in PNG, JPEG, or GIF format. Enter HELP READ IMAGE for details.
Default:
    If no device is specified, the default device is PNG.
Synonyms:
    None
Device Notes:
    1. HARDWARE TEXT - The font can be specified with the SET GD FONG comamnd.

    2. COLOR - GD supports the full range of 88 colors supported by Dataplot.

    3. HARDWARE FILL - Solid area fills are done in hardware.

    4. DASH PATTERNS - The following dash patterns are available:
      • DASH - 3 pixels on, 3 pixels off;
      • DOT - 1 pixel on, 1 pixels off;
      • DASH2 - 4 pixels on, 2 pixels off
      • DASH3 - 3 pixels on, 3 pixels off, 1 pixel on, 1 pixel off;
      • DASH4 - 2 pixels on, 2 pixels off.
      • DASH5 - 2 pixels on, 1 pixels off, 1 pixel on, 1 pixel off;

    5. LINE WIDTH - Thick lines are generated in software.
    6. GRAPHICS INPUT - The CROSS-HAIR command is not supported

      for this device.

    7. The CHARACTER PIXEL option is supported on this device.
Related Commands:
    POSTSCRIPT = Direct graphical output to a Postscript device.
    HPGL = Direct graphical output to an HPGL device.
    SVG = Generate graphical output in Scalable Vector Graphics format.
    DEVICE = Specify certain actions for the graphics output.
Applications:
    Web Applications, Graphics Import Into Other Programs
Implementation Date:
    2001/02
    2008/04 - added support for hardware text
    2014/07 - upgraded to GD version 2.1, added support for BMP, WBPM, TGA, and TIFF formats
Program:
    SET IPL1NA PLOT1.PNG
    DEVICE 2 GD PNG
    DEVICE 2 PICTURE POINTS 400 300
    TITLE SAMPLE PNG PLOT
    PLOT X**2 FOR X = 1 1 9
    DEVICE 2 CLOSE
    SET IPL1NA PLOT2.PNG
    DEVICE 2 GD PNG
    DEVICE 2 PICTURE POINTS 500 400
    TITLE SECOND SAMPLE PNG PLOT
    PLOT X**3 FOR X = 1 1 9
    DEVICE 2 CLOSE

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 06/05/2001
Last updated: 06/14/2016

Please email comments on this WWW page to alan.heckert@nist.gov.