Graphics Interchange Format

Graphics Interchange Format (GIF)
Rozszerzenia pliku.gif
Typ MIMEimage/gif
ProducentCompuServe
Data opracowania1987
Typbezstratna kompresja grafiki rastrowej

GIF (ang. Graphics Interchange Format) – format pliku graficznego z kompresją bezstratną (opis niżej), stworzony w 1987 roku[1] przez firmę CompuServe. Pliki tego typu są powszechnie używane na stronach WWW, gdyż pozwalają na tworzenie prostych animacji ze zdefiniowanym kolorem tła jako przezroczystym i określonym opóźnieniem przy odtwarzaniu poszczególnych klatek animacji.

Podział obrazu na bloki pozwolił uzyskać 1859 kolorów

Panuje powszechne przekonanie, iż format GIF pozwala jedynie na użycie do 256 kolorów w jednym pliku obrazu, jednak w rzeczywistości odnosi się to do liczby kolorów mogących występować w pojedynczym bloku obrazu, a nie w całym pliku zawierającym obraz. Dlatego też, używając większej liczby bloków, możliwe jest zastosowanie formatu GIF do przechowywania na przykład fotografii bez utraty jakości / liczby kolorów. Przekonanie o ww. ograniczeniu najprawdopodobniej wynika z tego, że ogromna większość programów do obróbki grafiki rastrowej potrafi obsługiwać jedynie jeden blok na cały obraz (a ówczesny sprzęt potrafił wyświetlać właśnie maksymalnie 256 kolorów na ekranie) albo błędnie interpretuje wiele bloków jako poszczególne klatki animowanego GIF-a. Ograniczenie to wynika więc z niepełnej obsługi formatu, a nie z ograniczeń istniejących w nim samym. W pliku GIF, zawierającym kilka bloków obrazu, każdy z nich może zawierać 256 kolorów albo 255 kolorów i jeden kolor „przezroczysty”.

(c) Foto: Jonn Leffmann, CC BY 3.0
Prosty obraz GIF złożony z 3 różnych obrazów odtwarzanych po sobie
GIF z działaniem zamka błyskawicznego

Ze względu na to, iż do kompresji w formacie GIF może być używany algorytm LZW, na którym ciążą patenty w kilku krajach świata, w 1995 został opracowany konkurencyjny format PNG używający do kompresji algorytmu deflate.

Według organizacji Software Freedom Law Center 1 października 2006 wygasły wszystkie ograniczenia patentowe dotyczące formatu GIF i format ten można uznać za uwolniony[2].

Przypisy

Zobacz też

Media użyte na tej stronie

Duvor.gif
(c) Foto: Jonn Leffmann, CC BY 3.0
En enkel Gif, gjord av tre olika bilder, som repeteras i det oändliga.
Redirect arrow without text.svg
Redirect arrow, to be used in redirected articles in Wikipedias written from left to right. Without text.
SmallFullColourGIF.gif
Autor: GDallimore, Licencja: CC BY-SA 3.0
Important note when using this image in Wikipedia articles: do not use thumbnails or force a change in the size of the image! The Wikimedia thumbnailing processes hide the increase in colour depth.

A typical GIF file is limited to 256 colours. This limit can be overcome by taking advantage of the fact that a single GIF image may be formed from many frames, each frame having its own local palette of 256 colours, including 1 transparent "colour". These frames are most often used in animations by displaying them one after the other with an appropriate time delay. Instead, each frame can contain a portion of the full image having no more than 255 colours with the rest of the frame being transparent. If all the frames are displayed simultaneously (i.e., with a delay time between each of zero) a full colour image results.

The original 3,483 colour image
The animation first shows a 255 colour image generated from the full colour image shown to the right. Reducing the number of colours from the 3,483 in the original results in obvious transitions between regions of different colours. The image is then split into 9 smaller blocks. For each of those blocks, a separate frame is created from the original full colour image containing just the content of that block with the rest of the frame being a transparent colour. A local palette of up to 255 colours is generated for each block to recreate that portion of the original image as accurately as possible. All 9 frames are then displayed together to create the final image. The improvement in image quality is obvious and the resulting image has 1859 colours. Further improvements in image quality could be obtained by selecting the blocks more carefully such that each block has no more than 255 colours in the original image; the blocks also need not be contiguous regions. Alternatively, smaller blocks could be used: a 16x16 block has 256 pixels so would contain at most that many colours and would be a suitable choice for all but the most complex of images.

In practice, this technique for displaying full colour GIFs is rarely used due to its complexity and the existence of other file formats which can more easily display more than 256 colours. There are also technical limitations in the computer programs commonly available for both creating and displaying GIF files which make it unfeasible. For example, to reduce file sizes, many GIF creation programs generate a single global palette of colours across all frames of an animation rather than separate local palettes for each individual frame. Also, most programs for displaying GIFs, such as web browsers, have a minimum delay time that can exist between animation frames. Consequently, rather than all of the frames being displayed simultaneously, the image is built up gradually as each frame appears in sequence.

The delay between each frame of the animation is at least 0.1 seconds to ensure that all common desktop web browsers are able to display it correctly. Other display programs, such as those on mobile devices, may not render the animation correctly and thumbnails of the animation generated by Wikimedia apply a global palette across the whole animation, hiding the increase in colour depth. If it can be used at full size, or if you consider it acceptable to tell readers to click through to the full-size image, FullColourGIF is a larger and clearer version of this animation.

Each frame of the animation was created using Corel PaintShop Pro X5. The animation itself was created using Zoner GIF Animator 5, one of a limited number of programs capable of generating a separate local palette for each frame of an animation.
Zipper animated.gif
Autor: DemonDeLuxe (Dominique Toussaint), Licencja: CC-BY-SA-3.0
Animowany model zamka błyskawicznego.