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:
    The ability to generate graphics for web based applications is increasingly important. The three most common formats for web applications are:

    1. GIF
    2. JPEG
    3. PNG (Portable Network Graphics)

    GIF is the most popular format. However, Dataplot (and free software in general) will not support it due to patent issues. (NOTE 3/2006: The patent is no longer being enforced, so free software can now support GIF without paying a royalty).

    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).

    Built-in support is available for JPEG files on just about all graphics capable browsers. PNG is slightly less well supported, but it is gaining in popularity. In particular, reasonably current versions of Netscape and Internet Explorer provide built-in PNG viewers (i.e., no external plug-ins need to downloaded and installed), so it can be used with <img> tags in the same fashion as GIF and JPEG images.

    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 now 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 typeset quality fonts in Postscript can generate higher quality images.

    In addition to web applications, PNG and JPEG images provide an alternative for importing Dataplot graphics into word processors and other programs. Although Postscript images provide the highest quality graphics for this purpose, PNG and JPEG graphics do have some advantages. For example, for on screen Power Point slide shows, PNG may be preferred because the Dataplot Postscript files typically only display a blank grey box on the screen (Dataplot does not generate a bitmap preview for Postscript files). Also, Postscript files must be printed on a Postscript printer. PNG and JPEG files do not have this restriction.

    Dataplot uses the GD library, developed by the Boutell company, to generate PNG and JPEG files. This is the library used by Perl (and many other programs) to generate PNG images. GD in turn uses three additional libraries: zlib, libpng, and libjpeg. These libraries are all freely downloadable from the web. The URL for GD is (this site contains links to the other three libraries):

      http://www.boutell.com/gd

    The availability of the GD device driver in Dataplot is dependent on having these libraries built on the given platform. Currently, the status of the Dataplot executables provided by Dataplot is:

    1. Sun Solaris - both the PNG and JPEG drivers are available.
    2. SGI IRIS - only the the PNG driver is available.
    3. IBM AIX - only the PNG driver is available.
    4. Linux - both the PNG and JPEG drivers are available (built for Red Hat Version 7.0).
    5. DEC Alpha - both the PNG and JPEG drivers are available
    6. Windows 95/98/NT - under development

    Note that if you need to build the Dataplot executable from source, then you also have to build the underlying GD libraries. The current version of Dataplot uses:

    1. GD-1.8.4
    2. zlib-1.1.3
    3. libpng-1.0.9
    4. jpeg-6b

    If you build from source, it is recommended that you use these versions of the libraries. Other versions may in fact work, but they will not have been explicitly tested with the Dataplot interface.

      NOTE: For some platforms, the 3/2006 version of Dataplot was upgraded to use:

      1. GD-2.0.33
      2. zlib-1.2.3
      3. libpng-1.2.8
      4. jpeg-6b

      Specifically, the pre-built executables for Linux, Cygwin, and Solaris use the updated versions of the libraries. We anticipate upgrading several of the other pre-built executables in the near future.

      Since many installations provide these libraries independent of Dataplot, we wanted to make Dataplot reasonably current. The primary substantive difference is that version 2.0.33 of GD now supports GIF files. Dataplot executables built with 1.84 will not support GIF while those built with version 2.0.33 will support GIF.

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

    This form designates device 1 as an GD graphics device.

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

    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 Ghostscript is now available for Windows and Unix platforms. For details, enter

      HELP POSTSCRIPT CONVERT
    The primary disadvantage to this method is that you cannot automatically generate landscape plots (you will need to use an image conversion program or have your application rotate the plot).

    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 the use of the Free Type library to use true type fonts with the GD library. Dataplot does not currently support this (text is drawn using one of the Dataplot software fonts). However, we are investigating this for future releases.
Default:
    If PNG/JPEG is omitted, the default device is PNG.
Synonyms:
    None
Device Notes:
    1. HARDWARE TEXT - The GD device currently does not support hardware characters (the font is set to SIMPLEX when the device is initialized). Support for True Type fonts is being investigated.

    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
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.