OUR FREE ONLINE TOOLS: Imgur Downloader Youtube Downloader Vimeo Downloader Instagram Downloader (new) Find Subtitles File Detective Subtitle Converter File Extensions Currency Converter Image Converter
Images \ Raster images \ .gif - CompuServe Graphics Interchange Format

What is .gif file?

CompuServe Graphics Interchange Format is a raster image. It was created by CompuServe in 1987.
Images are compressed.
Files always begin with ASCII string "GIF8".
File extension is .gif.

Software handling .gif files

Rest7 Free Online Converter

Structure of .gif images

The header is 13 bytes long.
Name Type Description
Magic Char8[6] = 'GIF87a' or 'GIF89a'
LogicalWidth UInt16
LogicalHeight UInt16
GlobalTable UInt8 bit #0 = Global Color Table Flag (GCTF)
bit #1 - #3 = Color Resolution
bit #4 = Sort Flag to Global Color Table
bit #5 - #7: Size of Global Color Table (SGCT): 2^(1+n)
BgColorIndex UInt8
PixelAspectRation UInt8

Global Palette

if GCTF = 1 then Global Palette is present after the header. It has 0-255 entries, each is 24 bit RGB. Number of entries is defined by SGCT.

Image Block

Name Type Description
Separator UInt8 = 0x2C
X UInt16 Left Position of Image
Y UInt16 Top Position of Image
Width UInt16
Height UInt16
LocalTable UInt8 bit #0 = Local Color Table Flag (LCTF)
bit #1 = Interce Flag
bit #2 = Sort Flag
bit #3 = Reserved
bit #4 - #7: Size of Local Color Table (SGCT): 2^(1+n)

Local Palette

if LCTF = 1 then Local Palette is present after the previous segment. It has 0-255 entries, each is 24 bit RGB. Number of entries is defined by SGCT.

Graphic Control Extension Block

This block is present only in GIF89a.
Name Type Description
Separator UInt8 = 0x21
ControlLabel UInt8 = 0xF9
Block Size UInt8 = 4
Flags UInt8 bit #0 - #2 = Reserved
bit #3 - #5 = Disposal Method
bit #6 = User Input Flag
bit #7 = Transparent Color Flag
Delay Time UInt16 * 1/100 second
TransparentColorIndex UInt8
Block Terminator UInt8 = 0

Trailer Block

This is the last segment. It's a single byte = 0x3B

More details about GIF format

Specification GIF 87a
Specification GIF 89a




Data types:
UInt8, UInt16, UInt32, UInt64 - Unsigned Integer 8 bit, 16 bit, 32 bit, 64 bit
Int8, Int16, Int32, Int64 - Signed Integer 8 bit, 16 bit, 32 bit, 64 bit
UMint16, UMint32 - Unsigned Motorola Integer 16 bit, 32 bit (Big Endian)
Char8, Char16 - Char 8 bit, 16 bit

Real world .gif samples

Here are some real world example pictures.



Rest7 Webtools Contact Usage Agreements Image Converter

Some icons by Freepik (CC BY 3.0)

Copyright © 2015 by rest7.com. All rights reserved.