Wolfram Language & System 10.0 (2014)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

GIF (.gif)

  • Import and Export fully support the GIF89a standard for both static and animated GIF images.


    Registered MIME type: image/gif
    GIF raster image format.
    Commonly used for static and animated graphics on the web.
    GIF is an acronym for Graphics Interchange Format.
    Binary format.
    Uses LZW lossless compression after restriction to an 8bit color palette.
    Supports transparency.
    Developed in 1987 by CompuServe.

Import and ExportImport and Export

  • Import["file.gif"] imports a GIF file, returning a single Image object or a list of images.
  • Export["file.gif",expr] exports graphics, images, or any other expression to GIF.
  • Export["file.gif",{g1,g2,}] exports a list of graphics or images as an animation.
  • When exporting Wolfram Language graphics or arbitrary expressions to GIF, the resulting image has the same raster size as its displayed form.
  • Image objects are by default exported at their raster size.
  • Because GIF is a raster image format, all fonts are rasterized on export.
  • Import["file.gif",elem] imports the specified element from a GIF file.
  • Import["file.gif",{elem,sub,}] imports a subelement.
  • Import["file.gif",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file", "GIF"] or Import["file",{"GIF",elem,}].
  • Export["file.gif",expr, elem] creates a GIF file by treating expr as specifying element elem.
  • Export["file.gif",{expr1,expr2,},{{elem1,elem2,}}] treats each as specifying the corresponding .
  • Export["file.gif",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.gif",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the GIF format.

Notebook InterfaceNotebook Interface

  • In the notebook front end, Insert Picture and the Open menu allow import of a GIF file into a cell.
  • Save Selection As exports the selected part of a notebook as a GIF file.


  • General Import elements:
  • "Elements"list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Animation"animated GIF represented as an animation object
    "Graphics"first frame of a GIF file, given as a Graphics object
    "GraphicsList"frames of an animated GIF as a list of Graphics objects
    "Image"first frame of a GIF file, given as an Image object
    "ImageList"frames of an animated GIF as a list of Image objects
  • Import by default uses the element for a static GIF, and for an animated GIF.
  • Import of an animated GIF with element gives the first frame of the animation.
  • Export by default generates an animated GIF if the expression supplied is a list of images, and a static GIF otherwise.
  • Export with element or always generates a static GIF.
  • Advanced data representation elements:
  • "Data"array of RGB color values
    "GrayLevels"array of normalized gray-level values
    "RGBColorArray"array of RGBColor objects
  • For animated GIFs, the above data representation elements are taken to be lists of the respective expressions.
  • Advanced Import elements:
  • "AnimationRepetitions"how many times the animation is played before stopping
    "Background"background color shown in transparent image regions
    "BitDepth"bits used to represent each color channel in the file
    "ColorMap"color reduction palette, given as a list of color values
    "GlobalColorMap"color palette used by default for individual animation frames
    "DisplayDurations"display durations of animation frames, given in seconds
    "ImageCount"number of frames in an animated GIF
    "ImageSize"overall image size
    "RawData"array of color map indices
    "Comments"user comments stored in the file
  • Importing the element from an animated GIF will return the color maps of all frames as a list.


  • General options:
  • BackgroundAutomaticbackground color shown in transparent image regions
    ImageSizeAutomaticoverall image size
  • Images are by default exported at full size.
  • Import and Export option:
  • "ImageTopOrientation"Toporientation of the image as stored in the file
  • Export options:
  • "DitheringMethod""FloydSteinberg"dithering algorithm used for generating the color-reduction table
    "TransparentColor"Automaticcolor to be interpreted as transparent
  • Export["file.gif",expr,"TransparentColor"->White] creates a GIF file in which all white pixels of the original image are taken to be transparent.
  • Possible settings for are or None.
  • Detailed properties and settings for an animated GIF:
  • "DisplayDurations"Automaticdisplay duration for each frame in seconds
    "Interlaced"Falsewhether to store graphics in interlaced form to allow progressive rendering
    AnimationRepetitions1how many times the animation plays before stopping
  • GIF supports color palettes of at most 256 colors, always storing colors at a resolution of 8 bits per color channel.
  • specifies the display durations for each frame in an animated GIF. If the list of display durations is shorter than the number of frames, the sequence is repeated as necessary.
  • With the default setting "DisplayDurations"-> Automatic, the display time will vary on different viewer applications.
  • The following settings can be given for AnimationRepetitions:
  • npositive integer, specifying how many times the animation should be played
    Infinityanimation is repeated indefinitely

ExamplesExamplesopen allclose all

Basic Examples  (5)Basic Examples  (5)

Import a raster image from a GIF file:

Click for copyable input

Export an image object to GIF:

Click for copyable input

Read an animated GIF as a list of images:

Click for copyable input

Import this file as an animation:

Click for copyable input

This rasterizes an arbitrary expression and converts the result to a GIF file:

Click for copyable input

Import the resulting file:

Click for copyable input

Create an animated GIF by exporting a list of Graphics expressions:

Click for copyable input

Import the resulting file as an animation:

Click for copyable input
Introduced in 1999
| Updated in 2008