The READ_GIF procedure reads the contents of a GIF format image file and returns the image and color table vectors (if present) in the form of IDL variables.

Although the GIF format allows files to contain multiple images, READ_GIF only reads in the first image in a file. Only 8-bit images are supported, and local colormaps are not supported.

This routine is written in the IDL language. Its source code can be found in the file in the lib subdirectory of the IDL distribution.

Calling Sequence

READ_GIF, Filename, Image [, R, G, B]



A scalar string specifying the full path name of the image file to read.


A named variable that will contain the image data read from the file.

R, G, B

Named variables that will contain the Red, Green, and Blue color vectors, if the rasterfile contains colormaps.



Set this keyword to close any open files. The CLOSE keyword is only useful if a file containing multiple images (as specified by the MULTIPLE keyword) is in use. Note that you do not need to specify the normal arguments to READ_GIF ( Filename , Image , etc.) when using this keyword.


Set this keyword to read files that contain multiple images. Each call to READ_GIF returns the next image, with the file remaining open between calls. The Filename argument is ignored and may be omitted after the first call. Reading past the last image returns a scalar value of -1 in the variable specified in the Image argument, and closes the file. R, G, and B color vectors are returned only once, along with the first image.


To open and read the GIF image file named foo.gif in the current directory, store the image in the variable image1.

READ_GIF, 'foo.gif', image1, R, G, B ; Store the color vectors in the variables R, G, and B.

TVLCT, R, G, B ; load the new color table and display the image.

TV, image1

See Also