Tgif Home
About Tgif
Current Release & Download
Copyright Info
A Screendump of Tgif
Release History
Tools That Tgif Uses
Tools That Work with Tgif
Author of Tgif
Miscellaneous Info
Return to Tgif's Home Page
William Chia-Wei Cheng

Tgif FAQ - Export & Print

Export Basics
Tgif does not have an Export command. It uses Print() from the File Menu to export. The 2nd icon in the 2nd row in the window of icons determines the export format. You can click on it with the left or right mouse buttons to cycle through available formats. What's displayed is referred as the current export format.

Certain formats may have color versions. For example, PostScript can be in colors; X11 Pixmap format can be considered to be the color version of X11 Bitmap format. To toggle between the black-and-white and color version of a format, one can select ColorPS() or BlkWhtPS() from the Layout Menu (or type <Meta><Cntrl>k). Holding down the middle mouse button when your mouse is above the 2nd icon in the 2nd row in the window of icons also gets the Layout Menu. When tgif is in the color-printing mode, the 2nd icon in the 2nd row should be the same color as the current color.

I thought the first line of an EPS file should be something like "%!PS-Adobe-3.0 EPSF-3.0". But the EPS file produced by tgif starts with just "%!". What's wrong?
If you are running tgif interactively, please use the following X default:

Tgif.UsePsAdobeString: 3.0/3.0

If you are running tgif with the "-print" command line option, please also use the "-adobe=3.0/3.0" command line option.

If you want to produce EPS file for Windows, please look at the Export Windows EPS File FAQ page.

I have an obj file generated by gnuplot. When I tried to export it to EPS using "tgif -print -color -eps", I get a message saying that "File does not contain enough color information (it is not saved by tgif-3.0-p10 or beyond)" and tgif was aborted. What should I do?
An obj file generated by gnuplot indeed does not contain enough color information. Therefore, if you ask tgif to export to color EPS file, it doesn't know how to do that. One place that has the needed color information is your X server and you can force tgif to use color information from your X server. Please try

tgif -print -color -eps -display $DISPLAY [filename]

This assumes that your $DISPALY environment variable is valid. This environment variable is automatically used by tgif when you run tgif interactively. So, if you can run tgif interactively, your $DISPALY environment variable is most likely setup correctly already.

Export GIF and Tgif.XpmToGif
To export a drawing in the GIF format, first you should set the current export format to GIF/ISMAP. If you then do a Print() from the File Menu, the content will be exported in the GIF format. Since tgif doesn't have a license to generate GIF files, it uses xpmtoppm and ppmtogif from the netpbm toolkit to generate GIF files. You can replace the default mechanism by using the Tgif.XpmToGif X resource. If you don't specify that resource, the default value of Tgif.XpmToGif is:

Tgif.XpmToGif: xpmtoppm %s | ppmtogif

It can be replaced with:

Tgif.XpmToGif: xpmtoppm %s | ppmtogif | giftrans -t gray75

to generate transparent GIFs. Giftrans is available from

What does the error message "xpmtoppm: can't open color names database - reconfigure with correct RGBDEF" mean when exporting a GIF file?
You get this error message because the machine on which xpmtoppm was compiled has a different path to rgb.txt than the machine from which you are running xpmtoppm. It's unfortunate that the hardcoded path is compiled into xpmtoppm. Rgb.txt is */lib/X11/rgb.txt under the X directory (which can also be /usr/openwin).

The simplest way to fix this is to login as root and add symbolic links so that rgb.txt can be found in the same path on different machines.

Another way to reconfigure is to recompile and reinstall the netpbm package. You can get the netpbm package from the /R5contrib directory on But if you reinstall it, that means that xpmtoppm won't work on the other machine (unless you hardcode the path to point to /usr/openwin/lib/X11/rgb.txt -- then it would work on all SUN machines -- but it may not work on HP machines).

Another way is to see the section on netpbm on tgif's home page and get the modified netpbm (netpbm-15nov1997.tar.gz). If you install that copy, you can set an RGB_DB environment variable to point to where rgb.txt is. The difference between the official netpbm and the new one and installation instructions of the new one are described in

What does the error message "xpmtoppm: missing or invalid format mean when exporting a GIF file on Red Hat Linux 7.2 system?
Tgif generates a GIF file by first generating an XPM file and then convert the XPM file to a GIF file using something like xpmtoppm and ppmtogif from the netpbm package. (Please also see above regarding Tgif.XpmToGif above.)

By default, tgif generates XPM format version 1 files. The old xpmtoppm program from the netpbm package can only handle XPM format verion 1 files. The xpmtoppm distributed with Red Hat 7.2 (and conceivably future versions) can only handle XPM format version 3 files. When it sees a format verion 1 XPM file, you will see the above error message.

The way to fix it is to force tgif to generate XPM format version 3 files. This can be done by setting the following X resources:

Tgif.XPmOutputVersion: 3
Tgif.UseXPmVersion1ForImageMap: false

Please remeber to run xrdb to refresh your X resource database if needed on your system.

Because of the way tgif calculate object sizes, you may get extra pixels around a GIF file. To get rid of the extra pixels, you can use SetExportPixelTrim() from the File Menu before doing the Print(). Setting the trim to "1 2 3 4" removes 1 pixel from the left, 2 pixels form the top, 3 pixels from the right, and 4 pixels from the bottom. The value of "0 0 1 1" is a good one to try (which removes 1 pixel from the right and 1 pixel from the bottom).
What does the error message "xpmtoppm: line too long ppmtogif: EOF / read error reading magic number" mean?
I think you get this error message because the image you are trying to generate is too wide. The xpmtoppm program has a hardcoded maximum line length (please look for MAX_LINE in "xpmtoppm.c"). You can change the value of MAX_LINE and recompile and reinstall xpmtoppm.

I don't know of a way to get around this problem, other than trying not to provide a wide image file.

HORI Kuniko <> suggested that one can use convert (part of ImageMagick) instead of xpmtoppm. Please try adding the following 3 lines to your X default file:

Tgif.XPmOutputVersion: 3
Tgif.UseXPmVersion1ForImageMap: false
Tgif.XpmToPng: convert %s png:-