Microsoft Store
 

GIF


 

GIF (Graphics Interchange Format) is a bitmap image format for pictures that use 256 (or fewer) distinct colors (though there is a workaround for this limitation). and animations that use 256 (or fewer) distinct colors per frame. GIFs are compressed files, and are employed specifically to reduce the amount of time it takes to transfer images over a network connection. The format was introduced by CompuServe in 1987 and has since come into widespread usage on the World Wide Web.

Colour

GIF is palette based: although any colour can be one of millions of shades, the maximum number of colours available for each frame is 256, which are stored in a "palette", a table which associates each colour number with an actual colour value. The limitation to 256 colours seemed reasonable at the time of GIF's creation because few people had the hardware to display more. Simple graphics, line drawings, cartoons, and grayscale photographs typically need fewer than 256 colours. Optionally, one of the colours in the palette can be set as transparent, hence achieving simple binary transparency.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

There exist ways to dither colour photographs by alternating pixels of 2 or more different colours to approximate an in-between colour, but this transformation inevitably loses some detail, and the algorithms to select colours and to perform the dithering vary widely in output quality, giving dithering a possibly unwarranted bad reputation. Additionally, dithering significantly reduces the image's compressibility and thus works contrary to GIF's main purpose.

Related Topics:
Dither - Algorithm

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

In the early days of graphical web browsers 256 color screens were common and it was fairly common to make GIF images using the websafe palette which was based on the common parts of the standard Windows and Mac palettes. This ensured predictable display on 256 color screens but severely limited the choice of colors. Now that truecolour screens are the norm, optimised palettes make more sense when creating 256 color images, though their are still many sites on web design that advise use of the websafe palette.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

~ ~ ~ ~ ~ ~ ~ ~ ~ ~

GIF89a was designed based on the principle of rendering images (known as frames when used for animation) to a logical screen. Each image could optionally have its own palette, and the format provides flags to specify delay and waiting for user input (not widely supported by viewers) between them. This is the feature that is used to create animated GIFs, but it can also be used to losslessly store a 24-bit RGB (truecolour) image by splitting it up into pieces small enough to be encoded into a 256 colour palette and setting up the gif to render these with no delay on the logical screen (demo). Unfortunately, most web browsers seem to assume that this multi-image feature will only be used for animation and insert a minimum delay between images. There will be some filesize bloat from doing this, especially if the encoder doesn't support LZW for patent reasons. There are very few tools around that can easily produce truecolor GIFs, and it is rarely an appropriate format unless there is absolutely no other option.

~ ~ ~ ~ ~ ~ ~ ~ ~ ~