---
title: "GIF File Format"
canonical: https://www.graphicsmill.com/docs/gm5/GIFFileFormat.htm
product: "Graphics Mill 5.5 for .NET"
---

This documentation is for the old version. [Go to the latest Graphics Mill docs](https://www.graphicsmill.com/docs/gm/)

# GIF File Format
 
The GIF format was designed by Compuserve in 1987. Since then it has become very popular for general image exchange. There are two types of GIF files; GIF87a, the original standard of 1987 and GIF89a, the revised standard of 1989. All of these formats are available for reading in Graphics Mill for .NET and GIF89a format is available for saving. Main advantage of GIF89a against GIF87a is animation and transparency support.
 
The GIF format is a lossless format and is good for saving any type of image that has 256 colors (or shades of gray), or fewer. This format is suitable as a generalized format for image exchange, however if you need to save the image with more colors, you should choose [PNG](https://www.graphicsmill.com/docs/gm5/PNGFileFormat.htm.md), [TIFF](https://www.graphicsmill.com/docs/gm5/TIFFFileFormat.htm.md) or [JPEG](https://www.graphicsmill.com/docs/gm5/JPEGFileFormat.htm.md) instead of GIF. In general this is the best format for images with a limited number of colors, since the compression ratio is good (it is difficult to obtain better compression and stay lossless) and GIF files can be decompressed very quickly. GIF image format supports one-dimensional interlacing (a method of progressive display), this makes this format convenient for transmission images across slow communication links. That is why this format is very popular for Web graphics.
 
## Format Name
  
GIF
 
## MIME Type
  
image/gif
 
## File Extensions
  
\*.gif
 
## Supported Pixel Formats
  
|  Description |  Read |  Write |
| --- | --- | --- |
 |  1 bit palette-based |  Yes |  Yes |
 |  4 bit palette-based |  Yes |  Yes |
 |  8 bit palette-based |  Yes |  Yes |
 
## Encoder Options
  
|  Name |  Default Value |  Comments |
| --- | --- | --- |
 |  [GifEncoderOptions.BackgroundEntryIndex](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_BackgroundEntryIndex.htm.md) <br> [GifWriter.BackgroundEntryIndex](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_BackgroundEntryIndex.htm.md) |  **-1** |  An index in the global palette for the background color. |
 |  [GifFrame.ColorKeyIndex](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifFrame_ColorKeyIndex.htm.md) |  **-1** |  Index of the transparent palette entry. If the frame has no transparent areas, -1 is returned. |
 |  [GifEncoderOptions.Delay](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_Delay.htm.md) <br> [GifFrame.Delay](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifFrame_Delay.htm.md) |  **0** |  Number of hundredths (1/100) of a second to wait after rendering the frame. |
 |  [GifEncoderOptions.DisposalMethod](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_DisposalMethod.htm.md) <br> [GifFrame.DisposalMethod](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifFrame_DisposalMethod.htm.md) |  [DisposalMethod.None](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Codecs_DisposalMethod.htm.md) |  Codecs.DisposalMethod value that specifies a disposal method for the frame. |
 |  [GifEncoderOptions.GlobalPalette](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_GlobalPalette.htm.md) <br> [GifWriter.GlobalPalette](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_GlobalPalette.htm.md) |  N/A |  [GraphicsMill.ColorPalette](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_ColorPalette.htm.md) class instance that specifies a global palette for the animated GIF. |
 |  [GifEncoderOptions.Height](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_Height.htm.md) <br> [GifWriter.Height](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_Height.htm.md) |  **0** |  Entire GIF file height (in pixels). |
 |  [GifEncoderOptions.Interlaced](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_Interlaced.htm.md) <br> [GifFrame.Interlaced](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifFrame_Interlaced.htm.md) |  `false` |  Value that specifies if the frame should be interlaced. |
 |  [GifEncoderOptions.LocalPaletteEnabled](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_LocalPaletteEnabled.htm.md) <br> [GifFrame.LocalPaletteEnabled](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifFrame_LocalPaletteEnabled.htm.md) |  `true` |  Value that specify if local palette of the frames should be saved. |
 |  [GifEncoderOptions.PlaybackCount](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_PlaybackCount.htm.md) <br> [GifWriter.PlaybackCount](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_PlaybackCount.htm.md) |  **0** |  A number of times to play the GIF file. If this property is 0, the file is played infinitely. |
 |  [GifEncoderOptions.Width](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifEncoderOptions_Width.htm.md) <br> [GifWriter.Width](https://www.graphicsmill.com/docs/gm5/P_Aurigma_GraphicsMill_Codecs_GifWriter_Width.htm.md) |  **0** |  Entire GIF file width (in pixels). |
 
## Examples
  
The following examples show how to work with simple GIF files. If you need to proccess animated files, see the [Loading and Saving Animated GIFs](https://www.graphicsmill.com/docs/gm5/LoadingandSavingAnimatedGIFs.htm.md) topic.
 
### Loading Simple GIF Files
 
Simple GIF files are the plain images without an animation. The simplest way to load such GIF file is to pass its name to the constructor:
 
```
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.gif")
```
 
```csharp
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.gif");
```
 
Alternatively, if you already have an instance of the [Bitmap](https://www.graphicsmill.com/docs/gm5/T_Aurigma_GraphicsMill_Bitmap.htm.md), you can use [Load](https://www.graphicsmill.com/docs/gm5/O_T_Aurigma_GraphicsMill_Bitmap_Load.htm.md) method:
 
```
Dim bitmap As New Aurigma.GraphicsMill.Bitmap
bitmap.Load("c:\Mountain.gif")
```
 
```csharp
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap();
bitmap.Load(@"c:\Mountain.gif");        
```
 
### Saving Simple GIF Files
 
Let's assume that we want to load a JPEG file and save this image as a web-optimized GIF file (for example, reduce number of colors to 32). This code example demonstrates how to do it:
 
```
Dim bitmap As New Aurigma.GraphicsMill.Bitmap("c:\Mountain.jpg")

bitmap.ColorManagement.PaletteEntryCount = 32
bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, _
    Nothing)

bitmap.Save("C:\Mountain.gif", _
    New Aurigma.GraphicsMill.Codecs.GifEncoderOptions)

bitmap.Dispose()
```
 
```csharp
using (Aurigma.GraphicsMill.Bitmap bitmap = 
           new Aurigma.GraphicsMill.Bitmap(@"c:\Mountain.jpg"))
{
    bitmap.ColorManagement.PaletteEntryCount = 32;
    bitmap.ColorManagement.ConvertToIndexed(8, Aurigma.GraphicsMill.ColorPaletteType.Adaptive, 
        null);

    bitmap.Save(@"C:\Mountain.gif", 
        new Aurigma.GraphicsMill.Codecs.GifEncoderOptions());
}
```
 
## See Also
  
### Manual
 
- [Loading and Saving Animated GIFs](https://www.graphicsmill.com/docs/gm5/LoadingandSavingAnimatedGIFs.htm.md)
