Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
GIF
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==File format== Conceptually, a GIF file describes a fixed-sized graphical area (the "logical screen") populated with zero or more "images". Many GIF files have a single image that fills the entire logical screen. Others divide the logical screen into separate sub-images. The images may also function as animation frames in an animated GIF file, but again these need not fill the entire logical screen. GIF files start with a fixed-length header ("GIF87a" or "GIF89a") giving the version, followed by a fixed-length [[Logical Screen Descriptor]] giving the pixel dimensions and other characteristics of the logical screen. The screen descriptor may also specify the presence and size of a [[Global Color Table]] (GCT), which follows next if present. Thereafter, the file is divided into segments of the following types, each introduced by a 1-byte sentinel: * An image (introduced by 0x2C, an ASCII comma {{code|','}}) * An extension block (introduced by 0x21, an ASCII exclamation point {{code|'!'}}) * The trailer (a single byte of value 0x3B, an ASCII semicolon {{code|';'}}), which should be the last byte of the file. An image starts with a fixed-length [[Image Descriptor]], which may specify the presence and size of a [[Local Color Table]] (which follows next if present). The image data follows: one byte giving the bit width of the unencoded symbols (which must be at least 2 bits wide, even for bi-color images), followed by a series of sub-blocks containing the LZW-encoded data. Extension blocks (blocks that "extend" the 87a definition via a mechanism already defined in the 87a spec) consist of the sentinel, an additional byte specifying the type of extension, and a series of sub-blocks with the extension data. Extension blocks that modify an image (like the Graphic Control Extension that specifies the optional animation delay time and optional transparent background color) must immediately precede the segment with the image they refer to. Each sub-block begins with a byte giving the number of subsequent data bytes in the sub-block (1 to 255). The series of sub-blocks is terminated by an empty sub-block (a 0 byte). This structure allows the file to be parsed even if not all parts are understood. A GIF marked 87a may contain extension blocks; the intent is that a decoder can read and display the file without the features covered in extensions it does not understand. The full detail of the file format is covered in the GIF specification.<ref name="89aSpec"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)