The Graphics Interchange Format (GIF) was developed by Compuserve Information Service to encode graphical images. It is another implementation of the LZW algorithm and is very similar to the compress command. The compressed image is stored with the first byte
being the minimum number of bits b per pixel in the original image. For the images we have been using as examples, this would be eight. The binary number 2b is defined to be the clear code. This code is used to reset all compression and decompression parameters to a start-up state. The initial size of the dictionary is 2b+1. When this fills up, the dictionary size is doubled, as was done in the compress algorithm, until the maximum dictionary size of 4096 is reached. At this point the compression algorithm behaves like a static dictionary algorithm. The codewords from the LZW algorithm are stored in blocks of characters. The characters are 8 bits long, and the maximum block size is 255. Each block is preceded by a header that contains the block size. The block is terminated by a block terminator consisting of eight 0s. The end of the compressed image is denoted by an end-of-information code with a value of 2b + 1. This codeword should appear before the block terminator.