SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Contacts SED Projects SED Products and Publications Search SED Pages
Dataplot Vol 1 Auxiliary Chapter

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 1/2009) are as follows:

      GD library (2.0.36) - http://www.libgd.org/
      zlib (1.2.3) - http://www.zlib.net/
      png (1.2.34) - http://www.libpng.org/pub/png
      jpeg (6b) - http://www.ijg.org
      (not clear if this web site is still being maintained)
      Free Type (2.1.10) - http://www.freetype.org/

    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 OSX should support this capability. The GD library is not currently supported for the Microsoft Windows executables.

Syntax 1:
    GD <PNG/JPEG/GIF>
    where PNG specifies PNG output, JPEG specifies JPEG outout, and GIF specifies GIF output.

    This form designates device 1 as an GD graphics device.

Syntax 2:
    DEVICE <1/2/3> GD <PNG/JPEG/GIF>
    where PNG specifies PNG output, JPEG specifies JPEG outout, and GIF specifies GIF output.

    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

      HELP POSTSCRIPT CONVERT

    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:
    Dataplot also uses the GD library to read image data in PNG, JPEG, or GIF format. Enter HELP READ IMAGE for details.
Default:
    If PNG/JPEG is omitted, 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/2
    2008/4 - added support for hardware text
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

Date created: 6/5/2001
Last updated: 4/4/2003
Please email comments on this WWW page to alan.heckert@nist.gov.