Skip Navigation.

NWE Help: Graphics: Giftrans

NWE Home :: Help :: Graphics

yellow star on red background

What is giftrans?
The giftrans program allows you to make a single color in a GIF image transparent. With this technique, you can "eliminate" the background of an image. This makes it appear as though the remaining figure is floating freely on your web page.

How does it work?
Giftrans makes all of the pixels in an image of a particular color transparent. You designate the color using its hexadecimal code. The image program XV will help you determine the hexadecimal code for the color you wish to make transparent. For instance, the hexadecimal code for the red background in our example is #FF0000.

How do I use giftrans?

  1. Open an xterm shell and change to the directory that contains your image file (if you don't understand this instruction, please read our xterm shell help pages first).

  2. At the prompt, type:
    giftrans -t RGBCOLOR filename > newfilename
    (RGBCOLOR represents the hexadecimal code for the color you wish to make transparent,
    filename is the name for your original image file,
    and newfilename is the name for the new image with the transparent background.)

yellow star on transparent background

Our example
For example, to make the red background on the sample image transparent, you would type:
giftrans -t #FF0000 sample.gif > sample2.gif
On the right, you can see the result. The red background is now transparent. If you right-click on the image and choose "View image" you'll see the star by itself.