出典(authority):フリー百科事典『ウィキペディア(Wikipedia)』「2016/03/30 04:52:32」(JST)
GIFフォーマットによる自転する地球の画像。 |
|
拡張子 | .gif |
---|---|
MIME Type | image/gif |
タイプコード | GIF GIFf |
UTI | com.compuserve.gif |
マジックナンバー | GIF87a /GIF89a |
開発者 | CompuServe |
種別 | ビットマップ画像 |
テンプレートを表示 |
Graphics Interchange Format(グラフィックス・インターチェンジ・フォーマット、略称GIF)はCompuServeのPICSフォーラムで提唱された画像ファイルフォーマットの一つである。LZW特許を使用した画像圧縮が可能。一般的に用いられている拡張子は.gif。正しい読みは「ジフ」。「ギフ[1]」もしくは「ジー・アイ・エフ」と読まれることもあるが、設計者のSteve Wilhiteは、Oxford Dictionaries USA Word of the Year 2012 に "GIF" が選出された際のインタビューにおいて、「jif(ジフ)」が正しい発音であると語った[2]。
GIFは256色以下の画像を扱うことができる可逆圧縮形式のファイルフォーマットである。圧縮画像ファイルフォーマットでは歴史の長いもののひとつで、WebブラウザではJPEGと並んで標準的にサポートされる。圧縮形式の特性上、同一色が連続する画像の圧縮率が高くなるため、イラストやボタン画像など、使用色数の少ない画像への使用に適している。
GIF規格には1987年6月15日に公開されたGIF87aと1990年7月30日に公開されたGIF89aの2種類があり、GIF89aでは、透過GIFとGIFアニメーションがサポートされた。現在、使われている規格はGIF89aである。GIFフォーマットの著作権はCompuServeが所有するがその利用はライセンスフリーであったため日本以外でのパソコン通信をはじめとする画像交換の標準フォーマットとして使われていた(日本ではパソコン通信時代はMAGやPiが主流だった)。ただし、圧縮技術としてLZWを使用しているため、後述する特許権の問題が発生した。
GIF画像ファイルにはGIF画像識別文字列が埋め込まれており、画像ファイルの最初の6文字は必ず「GIF87a」もしくは「GIF89a」で始まっている。
またGIFフォーマットは以下の様な画像をサポートする。
GIFには、以下のような特徴的な拡張が行われており、かつ、Webブラウザでの表示サポートも比較的良好であることから、これらの機能を利用するためGIF形式が選択されることも多い。
なお、ほとんど用いられる事は無いが、非可逆圧縮もサポートしている。また、Webサイトを作成する際、「1x1ピクセルの透過GIF」を利用したデザイン調整をおこなうことがあり、そのような画像は「スペーサーGIF」と呼ばれている。
GIFは、データ圧縮アルゴリズムとして、1984年に発表されたLZWを使用しているが、このアルゴリズムについては米UNISYS社が特許権を取得していた。この点に関し、UNISYS社は、当初はGIFにおけるLZWアルゴリズムの利用に関し利用料を請求しない方針を採っていたが、GIFフォーマットの利用が広まり、Webブラウザで標準的にサポートされるようになると、GIFにおけるLZWの利用について利用料を請求する方針に転換した。
このことにより、GIF形式をサポートする画像編集ソフトウェアの制作者のみならず、そのソフトウェアを利用してGIF画像を制作した一般の利用者に対しても特許使用料が賦課される懸念が生じたため、GIF形式の特徴を備えたフリーな代替物としてPNGが開発された。
米国内では2003年6月20日にLZWの特許が失効し、日本国内でも2004年6月20日に特許が失効した。現在ではGIFは自由に使うことのできるフォーマットであると考えられている。そのため、現在、再びGIFは利用者が増え、一時的に公開が停止されていたGIFを生成・表示するソフトウェアも再公開されるようになっている。
しかし、現在インターネットの末端接続サービスがブロードバンド主体であり、また、端末であるパソコンの表現能力の飛躍的な向上により、フルカラー対応の圧縮形式(JPEGやPNGなど)の需要が高まり、256色までしか対応できないGIFの使用頻度は減少する事となった。また、GIFアニメーションの代わりに、高画質でギミックを組み込むことのできるAdobe Flashが利用される例も増加している。
以上のような理由から、以前より使用頻度は減少傾向にあるものの、長年にわたって使われてきた枯れたファイルフォーマットであり、対応しているソフトウェアも多いことから、現在においてもGIFが利用されるケースは少なくない。特に、バナーといわれる広告表示用の画像は、広告媒体の入稿規定により、ファイル容量の上限と共にファイル形式をGIFで指定するものも多い。
2008年現在、国内で発売されている携帯電話は、Docomo端末上ではGIF/JPEG、au、ソフトバンクモバイルは搭載ブラウザでGIF/JPEG/PNGが利用可能であり、画像の特性に合わせてGIFも積極的に利用されている。
|
A rotating globe in GIF format.
|
|
Filename extension | .gif |
---|---|
Internet media type | image/gif |
Type code | GIF GIFf |
Uniform Type Identifier (UTI) | com.compuserve.gif |
Magic number | GIF87a /GIF89a |
Developed by | CompuServe |
Initial release | 1987; 29 years ago (1987)[1] |
Latest release |
89a
(1989; 27 years ago (1989)[2]) |
Type of format | lossless bitmap image format |
Website | www |
The Graphics Interchange Format (better known by its acronym GIF /ˈdʒɪf/ JIF or /ˈɡɪf/ GHIF) is a bitmap image format that was introduced by CompuServe in 1987[1] and has since come into widespread usage on the World Wide Web due to its wide support and portability.
The format supports up to 8 bits per pixel for each image, allowing a single image to reference its own palette of up to 256 different colors chosen from the 24-bit RGB color space. It also supports animations and allows a separate palette of up to 256 colors for each frame. These palette limitations make the GIF format less suitable for reproducing color photographs and other images with continuous color, but it is well-suited for simpler images such as graphics or logos with solid areas of color.
GIF images are compressed using the Lempel–Ziv–Welch (LZW) lossless data compression technique to reduce the file size without degrading the visual quality. This compression technique was patented in 1985. Controversy over the licensing agreement between the software patent holder, Unisys, and CompuServe in 1994 spurred the development of the Portable Network Graphics (PNG) standard. By 2004 all the relevant patents had expired.
CompuServe introduced the GIF format in 1987 to provide a color image format for their file downloading areas, replacing their earlier run-length encoding (RLE) format, which was black and white only. GIF became popular because it used LZW data compression, which was more efficient than the run-length encoding that formats such as PCX and MacPaint used, and fairly large images could therefore be downloaded in a reasonably short time, even with very slow modems.
The original version of the GIF format was called 87a.[1] In 1989, CompuServe released an enhanced version, called 89a,[2] which added support for animation delays (multiple images in a stream were already supported in 87a), transparent background colors, and storage of application-specific metadata. The 89a specification also supports incorporating text labels as text (not embedding them in the graphical data), but as there is little control over display fonts, this feature is not widely used. The two versions can be distinguished by looking at the first six bytes of the file (the "magic number" or "signature"), which, when interpreted as ASCII, read "GIF87a" and "GIF89a", respectively.
GIF was one of the first two image formats commonly used on Web sites, the other being the black-and-white XBM.[citation needed]
The feature of storing multiple images in one file, accompanied by control data, is used extensively on the Web to produce simple animations. The optional interlacing feature, which stores image scan lines out of order in such a fashion that even a partially downloaded image was somewhat recognizable, also helped GIF's popularity,[citation needed] as a user could abort the download if it was not what was required.
As a noun, the word GIF is found in the newer editions of many dictionaries. In 2012, the American wing of the Oxford University Press recognized GIF as a verb as well, meaning "to create a GIF file", as in "GIFing was perfect medium for sharing scenes from the Summer Olympics". The press's lexicographers voted it their word of the year, saying that GIFs have evolved into "a tool with serious applications including research and journalism".[3][4]
In May 2015 Facebook added GIF support after originally rejecting support.[5][6]
The creators of the format pronounced GIF as "jif" with a soft "G" /ˈdʒɪf/ as in "gin". Steve Wilhite says that the intended pronunciation deliberately echoes the American peanut butter brand, Jif, and CompuServe employees would often say "Choosy developers choose GIF", spoofing this brand's television commercials.[7]
An alternative pronunciation with a hard "G" (/ˈɡɪf/ as in "graphics", for which it stands) is in widespread usage.[8] The American Heritage Dictionary[9] cites both, acknowledging "jif" as the primary pronunciation, while Cambridge Dictionary of American English[10] offers only the hard-"G" pronunciation. Merriam-Webster's Collegiate Dictionary[11] and the OED[12] cite both pronunciations, but place "gif" in the default position ("\ˈgif, ˈjif\"). The New Oxford American Dictionary gave only "jif" in its 2nd edition[13] but updated it to "jif, gif" in its 3rd edition.[14]
The disagreement over the pronunciation led to heated Internet debate. On the occasion of receiving a lifetime achievement award at the 2013 Webby Award ceremony, Wilhite rejected the alternative pronunciation,[8][15][16] and his speech led to 17,000 posts on Twitter and 50 news articles.[17] The White House[8] and TV program Jeopardy![16] also waded into the debate during 2013.
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 size and other characteristics of the logical screen. The screen descriptor may also specify the presence and size of a Global Color Table, which follows next if present.
Thereafter, the file is divided into segments, each introduced by a 1-byte sentinel:
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 linked list 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 linked list 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.
The linked lists used by the image data and the extension blocks consist of series of sub-blocks, each sub-block beginning 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.[2]
GIF is palette-based: the colors used in an image (a frame) in the file have their RGB values defined in a palette table that can hold up to 256 entries, and the data for the image refer to the colors by their indices (0–255) in the palette table. The color definitions in the palette can be drawn from a color space of millions of shades (224 shades, 8 bits for each primary), but the maximum number of colors a frame can use is 256. This limitation seemed reasonable when GIF was developed because few people could afford the hardware to display more colors simultaneously. Simple graphics, line drawings, cartoons, and grey-scale photographs typically need fewer than 256 colors.
Each frame can designate one index as a "transparent background color": any pixel assigned this index takes on the color of the pixel in the same position from the background, which may have been determined by a previous frame of animation.
Many techniques, collectively called dithering, have been developed to approximate a wider range of colors with a small color palette by using pixels of two or more colors to approximate in-between colors. These techniques sacrifice spatial resolution to approximate deeper color resolution. While not part of the GIF specification, dithering can of course be used in images subsequently encoded as GIF images. This is often not an ideal solution for GIF images, both because the loss of spatial resolution typically makes an image look fuzzy on the screen, and because the dithering patterns often interfere with the compressibility of the image data, working against GIF's main purpose.
In the early days of graphical web browsers[when?], graphics cards with 8-bit buffers (allowing only 256 colors) were common and it was fairly common to make GIF images using the websafe palette.[according to whom?]} This ensured predictable display, but severely limited the choice of colors. Now that 32-bit graphics cards, which support 24-bit color, are the norm[needs update], palettes can be populated with the optimum colors for individual images.
A small color table may suffice for small images, and keeping the color table small allows the file to be downloaded faster. Both the 87a and 89a specifications allow color tables of 2n colors for any n from 1 through 8. Most graphics applications will read and display GIF images with any of these table sizes; but some do not support all sizes when creating images. Tables of 2, 16, and 256 colors are widely supported.
Although the GIF format is almost never used for True Color images, it is possible to do so.[20][21] A GIF image can include multiple image blocks, each of which can have its own 256-color palette, and the blocks can be tiled to create a complete image. Alternatively, the GIF89a specification introduced the idea of a "transparent" color where each image block can include its own palette of 255 visible colors plus one transparent color. A complete image can be created by layering image blocks with the visible portion of each layer showing through the transparent portions of the layers above.
To render a full-color image as a GIF, the original image must be broken down into smaller regions having no more than 255 or 256 different colors. Each of these regions is then stored as a separate image block with its own local palette and when the image blocks are displayed together (either by tiling or by layering partially transparent image blocks) the complete, full-color image appears. For example, breaking an image into tiles of 16 by 16 pixels (256 pixels in total) ensures that no tile has more than the local palette limit of 256 colors, although larger tiles may be used and similar colors merged resulting in some loss of color information.[20]
Since each image block requires its own local color table, a GIF file having lots of image blocks can be very large, limiting the usefulness of full-color GIFs.[21] Additionally, not all GIF rendering programs handle tiled or layered images correctly. Many rendering programs interpret tiles or layers as animation frames and display them in sequence as an endless animation[20] with most web browsers automatically displaying the frames with a delay time of 0.1 seconds or more.[22][23][better source needed]
Microsoft's Paint program saves a small black-and-white image as the following GIF file. Paint does not make optimal use of the GIF format; due to the unnecessarily large color table (storing a full 256 colors instead of the used 2) and symbol width, this GIF file is not an efficient representation of the 15-pixel image (illustrated enlarged above).
Although the Graphics Control Extension block declares color index 16 (hexadecimal 10) to be transparent, that index is not used in the image. The only color indexes appearing in the image data are decimal 40 and 255, which the Global Color Table maps to black and white, respectively.
Note that the hex numbers in the following tables are in little-endian byte order, as the format specification prescribes.
byte# hexadecimal text or (hex) value Meaning 0: 47 49 46 38 39 61 GIF89a Header Logical Screen Descriptor 6: 03 00 3 - logical screen width in pixels 8: 05 00 5 - logical screen height in pixels A: F7 - GCT follows for 256 colors with resolution 3 x 8 bits/primary B: 00 0 - background color #0 C: 00 - default pixel aspect ratio R G B Global Color Table D: 00 00 00 0 0 0 - color #0 black 10: 80 00 00 128 0 0 - color #1 : : 85: 00 00 00 0 0 0 - color #40 black : : 30A: FF FF FF 255 255 255 - color #255 white 30D: 21 F9 Graphic Control Extension 30F: 04 4 - 4 bytes of GCE data follow 310: 01 - there is a transparent background color 311: 00 00 - delay for animation: not used 313: 10 16 - color #16 is transparent 314: 00 - end of GCE block 315: 2C Image Descriptor 316: 00 00 00 00 (0,0) - NW corner position of image in logical screen 31A: 03 00 05 00 (3,5) - image width and height in pixels 31E: 00 - no local color table 31F: 08 8 Start of image - LZW minimum code size 320: 0B 11 - 11 bytes of LZW encoded image data follow 321: 00 51 FC 1B 28 70 A0 C1 83 01 01 32C: 00 - end of image data 32D: 3B GIF file terminator
The image pixel data, scanned horizontally from top left, are converted by LZW encoding to codes that are then mapped into bytes for storing in the file. The pixel codes typically don't match the 8-bit size of the bytes, so the codes are packed into bytes by a "little-Endian" scheme: the least significant bit of the first code is stored in the least significant bit of the first byte, higher order bits of the code into higher order bits of the byte, spilling over into the low order bits of the next byte as necessary. Each subsequent code is stored starting at the least significant bit not already used.
This byte stream is stored in the file as a series of "sub-blocks". Each sub-block has a maximum length 255 bytes and is prefixed with a byte indicating the number of data bytes in the sub-block. The series of sub-blocks is terminated by an empty sub-block (a single 0 byte, indicating a sub-block with 0 data bytes).
For the sample image above the reversible mapping between 9-bit codes and bytes is shown below.
9-bit code (hex) |
Binary | Bytes (hex) |
---|---|---|
00000000 | 00 | |
100 | ||
0101000|1 | 51 | |
028 | ||
111111|00 | FC | |
0FF | ||
00011|011 | 1B | |
103 | ||
0010|1000 | 28 | |
102 | ||
011|10000 | 70 | |
103 | ||
10|100000 | A0 | |
106 | ||
1|1000001 | C1 | |
107 | ||
10000011 | 83 | |
00000001 | 01 | |
101 | ||
0000000|1 | 01 |
A slight compression is evident: pixel colors defined initially by 15 bytes are exactly represented by 12 code bytes including control codes. The encoding process that produces the 9-bit codes is shown below. A local string accumulates pixel color numbers from the palette, with no output action as long as the local string can be found in a code table. There is special treatment of the first two pixels that arrive before the table grows from its initial size by additions of strings. After each output code, the local string is initialized to the latest pixel color (that could not be included in the output code).
Table 9-bit string --> code code Action #0 | 000h Initialize root table of 9-bit codes palette | : colors | : #255 | 0FFh clr | 100h end | 101h | 100h Clear Pixel Local | color Palette string | BLACK #40 28 | 028h 1st pixel always to output WHITE #255 FF | String found in table 28 FF | 102h Always add 1st string to table FF | Initialize local string WHITE #255 FF FF | String not found in table | 0FFh - output code for previous string FF FF | 103h - add latest string to table FF | - initialize local string WHITE #255 FF FF | String found in table BLACK #40 FF FF 28 | String not found in table | 103h - output code for previous string FF FF 28 | 104h - add latest string to table 28 | - initialize local string WHITE #255 28 FF | String found in table WHITE #255 28 FF FF | String not found in table | 102h - output code for previous string 28 FF FF | 105h - add latest string to table FF | - initialize local string WHITE #255 FF FF | String found in table WHITE #255 FF FF FF | String not found in table | 103h - output code for previous string FF FF FF | 106h - add latest string to table FF | - initialize local string WHITE #255 FF FF | String found in table WHITE #255 FF FF FF | String found in table WHITE #255 FF FF FF FF | String not found in table | 106h - output code for previous string FF FF FF FF| 107h - add latest string to table FF | - initialize local string WHITE #255 FF FF | String found in table WHITE #255 FF FF FF | String found in table WHITE #255 FF FF FF FF | String found in table No more pixels 107h - output code for last string 101h End
For clarity the table is shown above as being built of strings of increasing length. That scheme can function but the table consumes an unpredictable amount of memory. Memory can be saved in practice by noting that each new string to be stored consists of a previously stored string augmented by one character. It is economical to store at each address only two words: an existing address and one character.
The LZW algorithm requires a search of the table for each pixel. A linear search through up to 4096 addresses would make the coding slow. In practice the codes can be stored in order of numerical value; this allows each search to be done by a SAR (Successive Approximation Register, as used in some ADCs), with only 12 magnitude comparisons. For this efficiency an extra table is needed to convert between codes and actual memory addresses; the extra table upkeeping is needed only when a new code is stored which happens at much less than pixel rate.
Decoding begins by mapping the stored bytes back to 9-bit codes. These are decoded to recover the pixel colors as shown below. A table identical to the one used in the encoder is built by adding strings by this rule:
Is incoming code found in table? YES: add string for local code followed by first byte of string for incoming code NO: add string for local code followed by copy of its own first byte
shift 9-bit ----> Local Table Pixel code code code --> string Palette color Action 100h 000h | #0 Initialize root table of 9-bit codes : | palette : | colors 0FFh | #255 100h | clr 101h | end 028h | #40 BLACK Decode 1st pixel 0FFh 028h | Incoming code found in table | #255 WHITE - output string from table 102h | 28 FF - add to table 103h 0FFh | Incoming code not found in table 103h | FF FF - add to table | - output string from table | #255 WHITE | #255 WHITE 102h 103h | Incoming code found in table | - output string from table | #40 BLACK | #255 WHITE 104h | FF FF 28 - add to table 103h 102h | Incoming code found in table | - output string from table | #255 WHITE | #255 WHITE 105h | 28 FF FF - add to table 106h 103h | Incoming code not found in table 106h | FF FF FF - add to table | - output string from table | #255 WHITE | #255 WHITE | #255 WHITE 107h 106h | Incoming code not found in table 107h | FF FF FF FF - add to table | - output string from table | #255 WHITE | #255 WHITE | #255 WHITE | #255 WHITE 101h | End
Shorter code lengths can be used for palettes smaller than the 256 colors in the example. If the palette is only 64 colors (so color indexes are 6 bits wide), the symbols can range from 0 to 63, and the symbol width can be taken to be 6 bits, with codes starting at 7 bits. In fact, the symbol width need not match the palette size: as long as the values decoded are always less than the number of colors in the palette, the symbols can be any width from 2 to 8, and the palette size any power of 2 from 2 to 256. For example, if only the first four colors (values 0 to 3) of the palette are used, the symbols can taken to be 2 bits wide with codes starting at 3 bits.
Conversely, the symbol width could be set at 8, even if only values 0 and 1 are used; these data would only require a 2-color table. Although there would be no point in encoding the file that way, something similar typically happens for bi-color images: the minimum symbol width is 2, even if only values 0 and 1 are used.
The code table initially contains codes that are one bit longer than the symbol size in order to accommodate the two special codes clr and end and codes for strings that are added during the process. When the table is full the code length increases to give space for more strings, up to a maximum code 4095 = FFF(hex). As the decoder builds its table it tracks these increases in code length and it is able to unpack incoming bytes accordingly.
The GIF encoding process can be modified to create a file without LZW compression that is still viewable as a GIF image. This technique was introduced originally as a way to avoid patent infringement. Uncompressed GIF can also be a useful intermediate format for a graphics programmer because individual pixels are accessible for reading or painting. An uncompressed GIF file can be converted to an ordinary GIF file simply by passing it through an image editor.
The modified encoding method ignores building the LZW table and emits only the root palette codes and the codes for CLEAR and STOP. This yields a simpler encoding (a 1-to-1 correspondence between code values and palette codes) but sacrifices all of the compression: each pixel in the image generates an output code indicating its color index. When processing an uncompressed GIF, a standard GIF decoder will not be prevented from writing strings to its dictionary table, but the code width must never increase since that triggers a different packing of bits to bytes.
If the symbol width is n, the codes of width n+1 fall naturally into two blocks: the lower block of 2n codes for coding single symbols, and the upper block of 2n codes that will be used by the decoder for sequences of length greater than one. Of that upper block, the first two codes are already taken: 2n for CLEAR and 2n + 1 for STOP. The decoder must also be prevented from using the last code in the upper block, 2n+1 − 1, because when the decoder fills that slot, it will increase the code width. Thus in the upper block there are 2n − 3 codes available to the decoder that won't trigger an increase in code width. Because the decoder is always one step behind in maintaining the table, it does not generate a table entry upon receiving the first code from the encoder, but will generate one for each succeeding code. Thus the encoder can generate 2n − 2 codes without triggering an increase in code width. Therefore the encoder must emit extra CLEAR codes at intervals of 2n − 2 codes or less to make the decoder reset the coding dictionary. The GIF standard allows such extra CLEAR codes to be inserted in the image data at any time. The composite data stream is partitioned into sub-blocks that each carry from 1 to 255 bytes.
For the sample 3x5 image above, the following 9-bit codes represent "clear" (100) followed by image pixels in scan order and "stop" (101).
9-bit codes: 100 028 0FF 0FF 0FF 028 0FF 0FF 0FF 0FF 0FF 0FF 0FF 0FF 0FF 0FF 101
After the above codes are mapped to bytes, the uncompressed file differs from the compressed file thus:
: 320: 14 20 20 bytes uncompressed image data follow 321: 00 51 FC FB F7 0F C5 BF 7F FF FE FD FB F7 EF DF BF 7F 01 01 335: 00 - end :
The trivial example of a large image of solid color demonstrates the variable-length LZW compression used in GIF files.
Code | Pixels | Notes | |||
---|---|---|---|---|---|
No. Ni |
Value Ni + 256 |
Length (bits) |
This code Ni |
Accumulated Ni(Ni + 1)/2 |
Relations using Ni only apply to same- color pixels until coding table is full. |
0 | 100h | 9 | Clear code table | ||
1 | FFh | 1 | 1 | Top left pixel color chosen as the highest index of a 256-color palette |
|
2 | 102h | 2 | 3 | ||
3 ⋮ |
103h ⋮ |
3 ⋮ |
6 ⋮ |
|
|
256 ⋮ |
200h ⋮ |
10 | 256 ⋮ |
32896 ⋮ |
|
768 ⋮ |
400h ⋮ |
11 | 768 ⋮ |
295296 ⋮ |
|
1792 ⋮ |
800h ⋮ |
12 | 1792 ⋮ |
1606528 ⋮ |
|
⋮ | FFFh | 3839 | The maximum code may repeat for more same-color pixels. Overall data compression asymptotically approaches |
||
101h | End of image data |
The code values shown are packed into bytes which are then packed into blocks of up to 255 bytes. A block of image data begins with a byte that declares the number of bytes to follow. The last block of data for an image is marked by a zero block-length byte.
The GIF Specification allows each image within the logical screen of a GIF file to specify that it is interlaced; i.e., that the order of the raster lines in its data block is not sequential. This allows a partial display of the image that can be recognized before the full image is painted.
An interlaced image is divided from top to bottom into strips 8 pixels high, and the rows of the image are presented in the following order:
The pixels within each line are not interlaced, but presented consecutively from left to right. As with non-interlaced images, there is no break between the data for one line and the data for the next. The indicator that an image is interlaced is a bit set in the image's header block.
This section requires expansion with: discussion of the accessibility problems, why most browsers enable animated gifs, and how users can block animated gifs. (May 2015) |
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, forming a video clip. 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).[24] 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.[25] 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 - bit-fields 3x:3:1:1, 000|010|0|0 -> Restore to bg color 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 color table; 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.[26]
In 1977 and 1978, Jacob Ziv and Abraham Lempel published a pair of papers on a new class of lossless data-compression algorithms, now collectively referred to as LZ77 and LZ78. In 1983, Terry Welch developed a fast variant of LZ78 which was named Lempel–Ziv–Welch (LZW).[27][28]
Welch filed a patent application for the LZW method in June 1983. The resulting patent, US 4558302 , granted in December 1985, was assigned to Sperry Corporation who subsequently merged with Burroughs Corporation in 1986 and formed Unisys.[27] Further patents were obtained in the United Kingdom, France, Germany, Italy, Japan and Canada.
In June 1984, an article by Welch was published in the IEEE magazine which publicly described the LZW technique for the first time.[29] LZW became a popular data compression technique and, when the patent was granted, Unisys entered into licensing agreements with over a hundred companies.[27][30]
The popularity of LZW led CompuServe to choose it as the compression technique for their GIF format, developed in 1987. At the time, CompuServe was not aware of the patent.[27] Unisys became aware that the GIF format used the LZW compression technique and entered into licensing negotiations with CompuServe in January 1993. The subsequent agreement was announced on 24 December 1994.[28] Unisys stated that they expected all major commercial on-line information services companies employing the LZW patent to license the technology from Unisys at a reasonable rate, but that they would not require licensing, or fees to be paid, for non-commercial, non-profit GIF-based applications, including those for use on the on-line services.[30]
Following this announcement, there was widespread condemnation of CompuServe and Unisys, and many software developers threatened to stop using the GIF format. The PNG format (see below) was developed in 1995 as an intended replacement.[27][28][29] However, obtaining support from the makers of Web browsers and other software for the PNG format proved difficult and it was not possible to replace the GIF format, although PNG has gradually increased in popularity.[27] Therefore, GIF variations without LZW compression were developed. For instance the libungif library, based on Eric S. Raymond's giflib, allows creation of GIFs that followed the data format but avoided the compression features, thus avoiding use of the Unisys LZW patent.[31] A 2001 Dr. Dobbs article described another alternative to LZW compression, based on square roots.[32]
In August 1999, Unisys changed the details of their licensing practice, announcing the option for owners of certain non-commercial and private websites to obtain licenses on payment of a one-time license fee of $5000 or $7500.[33] Such licenses were not required for website owners or other GIF users who had used licensed software to generate GIFs. Nevertheless, Unisys was subjected to thousands of online attacks and abusive emails from users believing that they were going to be charged $5000 or sued for using GIFs on their websites.[34] Despite giving free licenses to hundreds of non-profit organizations, schools and governments, Unisys was completely unable to generate any good publicity and continued to be condemned by individuals and organizations such as the League for Programming Freedom who started the "Burn All GIFs" campaign in 1999.[35][36]
The United States LZW patent expired on 20 June 2003.[37] The counterpart patents in the United Kingdom, France, Germany and Italy expired on 18 June 2004, the Japanese counterpart patents expired on 20 June 2004, and the counterpart Canadian patent expired on 7 July 2004.[37] Consequently, while Unisys has further patents and patent applications relating to improvements to the LZW technique,[37] the GIF format may now be used freely.[38]
Portable Network Graphics (PNG) was designed as a replacement for the GIF format in order to avoid infringement of Unisys' patent on the LZW compression technique.[27] PNG offers better compression and more features than GIF,[39] animation being the only significant exception. PNG is more suitable than GIF in instances where true-color imaging and alpha transparency are required.
Although support for PNG format came slowly, new web browsers generally support PNG. Older versions of Internet Explorer do not support all features of PNG. Versions 6 and earlier do not support alpha channel transparency without using Microsoft-specific HTML extensions.[40] Gamma correction of PNG images was not supported before version 8, and the display of these images in earlier versions may have the wrong tint.[41]
PNG files can be much larger than GIF files in situations where a GIF and a PNG file were created from the same high-quality image source, as PNG is capable of storing more color depth and transparency information than GIF. However, for identical 8-bit (or lower) image data, PNG files are typically smaller than the equivalent GIFs, due to the more efficient compression techniques used in PNG encoding.[42] Complete support for the GIF format is complicated chiefly by the complex canvas structure it allows, though this is what enables the compact animation features.
MNG was originally developed as a PNG-based solution for animations. MNG reached version 1.0 in 2001, but few applications support it.
In 2006, an extension to the PNG format called APNG was proposed as alternative to the MNG format by Mozilla. APNG provide the ability to animate PNG files, while retaining backwards compatibility in decoders that cannot understand the animation chunk (unlike MNG). Older decoders will simply render the first frame of the animation. The PNG group officially rejected APNG as an official extension on April 20, 2007.[43] There have been several subsequent proposals for a simple animated graphics format based on PNG using several different approaches.[44] Nevertheless, Animated Portable Network Graphics is still under development by Mozilla and is supported in Firefox 3[45][46] while MNG support was dropped.[47][48]
Embedded Adobe Flash objects and MPEGs are used on some websites to display simple video, but require the use of an additional browser plugin. WebM and WebP are in development and are supported by some web browsers.[49] Other options for web animation include serving individual frames using AJAX, or animating SVG images using JavaScript or SMIL.[citation needed]
With the introduction of widespread support of the HTML5 <video>
tag in most web browsers, some websites use a looped version of the video tag generated by JavaScript functions. This gives the appearance of a gif, but with the size and speed advantages of compressed video. A notable example is Imgur and their GIFV metaformat, which is really a video tag playing a looped MP4 or WebM compressed video.[50]
Computer graphics portal | |
Internet portal | |
Animation portal |
Wikimedia Commons has media related to GIF. |
|
|
全文を閲覧するには購読必要です。 To read the full text you will need to subscribe.
リンク元 | 「視床下部ホルモン」「成長抑制因子」 |
関連記事 | 「GI」「G」 |
成長ホルモン放出ホルモン | somatotrpin-releasing hormone | SRH | GH分泌↑ |
ソマトスタチン | growth hormone-inhibiting factor / somatostatin | GIF | GH分泌↓ |
甲状腺刺激ホルモン放出ホルモン | thyroid-stimulating hormone-relaing hormone | TRH | TSH分泌↑ |
副腎皮質刺激ホルモン放出ホルモン | corticotropin-releasing hormone | CRH | ACTH分泌↑ |
ゴナドトロピン放出ホルモン | gonadotropin-releasing hormone | GnRH | FSH分泌↑、LH分泌↑ |
プロラクチン放出因子 | prolactin-releasing factor | PRF | prolactin分泌↑ |
プロラクチン抑制因子 | prolactin-inhibiting factor | PIF | prolactin分泌↓ |
.