Graphics Interchange Format - Animated GIF

Animated GIF

Basic animation was added to the GIF89a spec via the Graphics Control Extension (GCE), which allows various images (frames) in the file to be painted with time delays. An animated GIF file comprises a number of frames that are displayed in succession, each introduced by its own GCE, which gives the time delay to wait after the frame is drawn. Global information at the start of the file applies by default to all frames. The data is stream-oriented, so the file-offset of the start of each GCE depends on the length of preceding data. Within each frame the LZW-coded image data is arranged in sub-blocks of up to 255 bytes; the size of each sub-block is declared by the byte that precedes it.

By default, however, an animation displays the sequence of frames only once, stopping when the last frame is displayed. Since GIF is designed to allow users to define new blocks, Netscape in the 1990s used the Application Extension block (intended to allow vendors to add application-specific information to the GIF file) to implement the Netscape Application Block (NAB). This block, placed immediately before all the animation frames, specifies the number of times the sequence of frames should be played. (The value 0 signifies continuous display.) Support for these repeating animations first appeared in Netscape Navigator version 2.0, and then spread to other browsers. Most browsers now recognize and support NAB, though it is not strictly part of the GIF89a specification.

The following example shows the structure of the animation file Rotating earth (large).gif shown (as a thumbnail) at the top of the article.

byte# hexadecimal text or (hex) value Meaning 0: 47 49 46 38 39 61 GIF89a Header Logical Screen Descriptor 6: 90 01 400 - width in pixels 8: 90 01 400 - height in pixels A: F7 - GCT follows for 256 colors with resolution 3 x 8bits/primary B: 00 0 - background color #0 C: 00 - default pixel aspect ratio D: Global Color Table : 30D: 21 FF Application Extension block 30F: 0B 11 - eleven bytes of data follow 310: 4E 45 54 53 43 41 50 45 NETSCAPE - 8-character application name 32 2E 30 2.0 - application "authentication code" 31B: 03 3 - three more bytes of data 31C: 01 1 - data sub-block index (always 1) 31D: FF FF 65535 - unsigned number of repetitions 31F: 00 - end of App Extension block 320: 21 F9 Graphic Control Extension for frame #1 322: 04 4 - four bytes of data follow 323: 08 - no transparency 324: 09 00 - 0.09 sec delay before painting next frame 326: 00 - no transparent color 327: 00 - end of GCE block 328: 2C Image Descriptor 329: 00 00 00 00 (0,0) - NW corner of frame at 0, 0 32D: 90 01 90 01 (400,400) - Frame width and height: 400 x 400 331: 00 - no local CT; no interlace 332: 08 8 LZW min code size 333: FF 255 - 255 bytes of LZW encoded image data follow 334: data 433: FF 255 - 255 bytes of LZW encoded image data follow data : 92BA: 00 - end of LZW data for this frame 92BB: 21 F9 Graphic Control Extension for frame #2 : : 153B7B:21 F9 Graphic Control Extension for frame #44 : 15CF35:3B File terminator

The animation delay for each frame is specified in the GCE in hundredths of a second. Some economy of data is possible where a frame need only rewrite a portion of the pixels of the display, because the Image Descriptor can define a smaller rectangle to be rescanned instead of the whole image. Displays that do not support animated GIFs show only the first frame.

Internet Explorer slows down GIFs if the frame-rate is 20 frames per second or higher and Microsoft reports that Google Chrome and Safari also slow down some GIF animations.

Read more about this topic:  Graphics Interchange Format

Famous quotes containing the word animated:

    Impenetrable in their dissimulation, cruel in their vengeance, tenacious in their purposes, unscrupulous as to their methods, animated by profound and hidden hatred for the tyranny of man—it is as though there exists among them an ever-present conspiracy toward domination, a sort of alliance like that subsisting among the priests of every country.
    Denis Diderot (1713–1784)