# GIF

**GIF**（Graphics Interchange Format，图形交换格式）是一种位图图像文件格式，由在线服务提供商[CompuServe](https://www.edgepedia.org/zh/compuserve)于1987年推出，是一种压缩彩色图形格式，其服务的所有成员均可使用。它以无损Lempel-Ziv-Welch（LZW）压缩和8位索引色存储图像，支持简单的基于帧的动画、隔行扫描和单色透明，至今仍是网络上使用最广泛的格式之一，MIME类型为`image/gif`。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 1987年由CompuServe推出；由史蒂夫·威尔海特（Steve Wilhite）领导的团队开发<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup><sup> • </sup><sup>[2](https://time.com/5791028/how-to-pronounce-gif/)</sup> |
| 色彩模型 | 8位索引色：每个像素是24位颜色调色板中的一个索引，调色板最多256个条目<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup> |
| 压缩 | 无损LZW；图像始终以压缩形式存储<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup><sup> • </sup><sup>[3](https://pronom.nationalarchives.gov.uk/fmt/4)</sup> |
| 版本 | GIF87a（1987年）和GIF89a（1990年），后者增加了用于渲染和动画定时的可选控制扩展<sup>[3](https://pronom.nationalarchives.gov.uk/fmt/4)</sup> |
| 最大尺寸 | 65,536 × 65,536像素<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup> |
| 专利状况 | LZW专利已到期（美国2003年6月；欧洲和日本2004年6月）；截至2004年7月7日，所有相关专利均已到期，该格式可自由使用<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000135.shtml)</sup><sup> • </sup><sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup> |
| 现代建议 | 适合基本图像和动画；无损静态图像首选PNG，动画序列首选WebP、AVIF或APNG<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup> |

## 历史

CompuServe于1987年推出GIF，为其文件下载区提供一种彩色图像格式，取代了此前仅支持黑白的游程编码（RLE）格式。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup><sup> • </sup><sup>[5](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000133.shtml)</sup>CompuServe工程师史蒂夫·威尔海特主持了这项工作，他的任务是开发一种既美观又下载迅速的图像格式——在那个2,400比特/秒的拨号速度被视为飞快的年代。<sup>[2](https://time.com/5791028/how-to-pronounce-gif/)</sup><sup> • </sup><sup>[6](https://www.fastcompany.com/90734869/history-of-gif-steve-wilhite)</sup>LZW压缩将大量图像信息打包进尽可能少的字节中，因此即使是相当大的图像，通过慢速调制解调器也能在合理时间内下载完成。<sup>[6](https://www.fastcompany.com/90734869/history-of-gif-steve-wilhite)</sup>

此后出现了两个版本。GIF87a是最初的规范；GIF89a由CompuServe于1990年7月31日发布，在87a版本基础上扩展了一系列可选的控制扩展，用于控制文件中图像的渲染方式，这是动画定时和透明处理的基础。<sup>[3](https://pronom.nationalarchives.gov.uk/fmt/4)</sup><sup> • </sup><sup>[7](https://paulbourke.net/dataformats/gif/)</sup>GIF是HTML最早支持的两种图形格式之一，另一种是XBM。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>

## 技术设计

**索引色。** GIF中的每个像素是一个8位值，作为24位颜色（红、绿、蓝各8位）颜色表的索引。颜色表的长度始终是2的幂，因此调色板有2、4、8、16、32、64或256个条目。为模拟超过256种颜色，通常使用抖动。技术上可以将多个图像块拼接，每块自带调色板，从而创建真彩色图像，但实践中很少这样做。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>该格式支持1至8位的位深，一个文件可以携带用于整个数据流的全局颜色表，或附加于单个图像的局部颜色表，后者优先于全局颜色表。<sup>[3](https://pronom.nationalarchives.gov.uk/fmt/4)</sup><sup> • </sup><sup>[8](https://giflib.sourceforge.net/gifstandard/GIF89a.html)</sup>

**文件结构。** GIF文件以文件头（Header）和逻辑屏幕描述符（Logical Screen Descriptor）开头，随后是一个或多个图像段，以文件尾（Trailer）结束。块分为三类：控制块（如文件头和图形控制扩展）、图形渲染块（如图像描述符）和特殊用途块（如注释扩展和应用扩展）。<sup>[3](https://pronom.nationalarchives.gov.uk/fmt/4)</sup><sup> • </sup><sup>[8](https://giflib.sourceforge.net/gifstandard/GIF89a.html)</sup>

**透明与隔行扫描。** 像素默认不透明，除非指定某个颜色索引为透明，此时该值的像素完全透明；该格式提供的是这种单色透明，而非逐像素alpha通道。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup><sup> • </sup><sup>[9](https://www.w3.org/Graphics/PNG/png-spec9.html)</sup>隔行扫描以乱序存储像素行，使部分接收的文件能以较低质量显示，这在慢速网络连接上很有用。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>

**动画。** GIF支持简单动画：在一个初始的全尺寸帧之后，一系列图像提供每一帧中发生变化的部分。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>89a规范本身指出：“图形交换格式并非为动画平台而设计，尽管可以以有限的方式实现。”<sup>[8](https://giflib.sourceforge.net/gifstandard/GIF89a.html)</sup>[动画](https://www.edgepedia.org/zh/animation)时长由三个变量决定：帧数、帧率（每帧显示多长时间，可逐帧设置）和重复次数；一个2帧图像，每帧0.5秒，重复3次，正好运行3秒。<sup>[10](https://www.w3.org/WAI/WCAG22/Techniques/general/G152.html)</sup>

## LZW专利争议

GIF使用的LZW算法曾获得专利，专利权归优利系统（Unisys）所有。从1994年底开始，优利系统采取了事后专利维权行动，要求对创建或显示GIF图像的软件收取版税；1994年12月24日，优利系统和CompuServe宣布他们预期将收取许可费。由于网络媒介对GIF图像的广泛使用，这些行动被认为对网络产生了不利影响。<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000135.shtml)</sup><sup> • </sup><sup>[11](https://gnkc.ac.in/assets/pdf/NAAC/ppt/MMT-Images%20BCA%20v%20sem.pdf)</sup>

反弹催生了新格式。PNG的开发由托马斯·博特尔（Thomas Boutell）领导，工作组最初选择了名称PING，意为“PING is not GIF”（PING不是GIF）；PNG被设计为无专利的替代品，还增加了GIF所缺乏的真彩色支持和完整alpha通道。<sup>[12](https://www.techradar.com/pro/how-a-dispute-over-royalties-gave-birth-to-the-png-file-format)</sup><sup> • </sup><sup>[9](https://www.w3.org/Graphics/PNG/png-spec9.html)</sup>对许可要求的反应从务实的方案（如PNG）到有组织的抗议不一而足；《[大西洋月刊](https://www.edgepedia.org/zh/the-atlantic)》称“烧掉所有GIF日”可能是首次针对数学算法的有组织政治抗议。<sup>[13](https://www.smithsonianmag.com/history/brief-history-gif-early-internet-innovation-ubiquitous-relic-180963543/)</sup>

专利按已知时间表到期：优利系统的美国专利于2003年6月到期，其欧洲和日本专利于2004年6月到期。MDN记载，截至2004年7月7日，所有相关专利均已到期，GIF格式可自由使用。<sup>[4](https://www.loc.gov/preservation/digital/formats/fdd/fdd000135.shtml)</sup><sup> • </sup><sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>

## 流行与现代替代方案

GIF因其简单性和兼容性而流行了数十年。其动画支持在社交媒体时代推动了复兴，动态GIF被广泛用于短“视频”、表情包和其他简单动画序列。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>史蒂夫·威尔海特当初预计该格式会用于彩色天气图；在2014年给《时代》周刊的一封电子邮件中，他谈到该格式意想不到的文化影响力：“我从没想过。”<sup>[14](https://time.com/2928183/gif-inventor/)</sup>

对于新项目，MDN建议无损和索引色静态图像使用PNG，动画序列使用[WebP](https://www.edgepedia.org/zh/webp)、AVIF或[APNG](https://www.edgepedia.org/zh/apng)；APNG由[Mozilla](https://www.edgepedia.org/zh/mozilla)推出，支持多种色深，而动态GIF仅支持8位索引色，PNG规范将APNG描述为传统上使用GIF的简单动态图像的替代品，增加了24位图像和8位透明度。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup><sup> • </sup><sup>[15](https://www.w3.org/TR/png-3/)</sup>将全彩照片转换为GIF可能因256色调色板而产生不理想的抖动效果。<sup>[1](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)</sup>

## 发音

自该格式流行以来，“GIF”的发音一直存在争议。史蒂夫·威尔海特称之为软g的GIF，据说他曾说“Choosy developers choose JIF”（挑剔的开发者选择JIF），这是对花生酱品牌Jif广告语的戏仿；在2013年威比奖上，他重申：“读作JIF，不是GIF。”<sup>[2](https://time.com/5791028/how-to-pronounce-gif/)</sup>牛津词典将GIF选为2012年美国年度词汇，同时接受giant中的软g和graphic中的硬g两种读法。<sup>[2](https://time.com/5791028/how-to-pronounce-gif/)</sup>公众人物和调查意见分歧：[贝拉克·奥巴马](https://www.edgepedia.org/zh/barack-obama)总统在2014年宣布他的“官方立场”是硬g，而2014年对1,000多名美国人的调查发现，“gift”式读法以约54%对41%击败“jiff”式读法。<sup>[2](https://time.com/5791028/how-to-pronounce-gif/)</sup>2020年，GIPHY与Jif花生酱合作推出限量版罐装产品，标签上写着“Gif”，GIPHY创始人兼首席执行官亚历克斯·钟（Alex Chung）表示，在GIPHY，GIF读作硬g，与Jif花生酱不同。<sup>[2](https://time.com/5791028/how-to-pronounce-gif/)</sup>

## References

1. [GIF (Graphics Interchange Format), Image file type and format guide, MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)
2. [Here's a Timeline of the Debate About How to Pronounce GIF, TIME](https://time.com/5791028/how-to-pronounce-gif/)
3. [Graphics Interchange Format 89a, PRONOM, The National Archives (UK)](https://pronom.nationalarchives.gov.uk/fmt/4)
4. [LZW Compression Encoding, Library of Congress Sustainability of Digital Formats](https://www.loc.gov/preservation/digital/formats/fdd/fdd000135.shtml)
5. [GIF Graphics Interchange Format, Version 89a, Library of Congress](https://wwws.loc.gov/preservation/digital/formats/fdd/fdd000133.shtml)
6. [How Steve Wilhite created GIF, the graphics format that ate the world, Fast Company](https://www.fastcompany.com/90734869/history-of-gif-steve-wilhite)
7. [Graphics Interchange Format Version 89a specification, CompuServe (31 July 1990), Paul Bourke mirror](https://paulbourke.net/dataformats/gif/)
8. [Graphics Interchange Format Version 89a, giflib specification mirror](https://giflib.sourceforge.net/gifstandard/GIF89a.html)
9. [PNG (Portable Network Graphics) Specification, Ninth Draft, W3C](https://www.w3.org/Graphics/PNG/png-spec9.html)
10. [G152: Setting animated gif images to stop blinking after n cycles, W3C Web Accessibility Initiative](https://www.w3.org/WAI/WCAG22/Techniques/general/G152.html)
11. [MMT Images course notes, GNKC (GIF licensing history)](https://gnkc.ac.in/assets/pdf/NAAC/ppt/MMT-Images%20BCA%20v%20sem.pdf)
12. [How a dispute over royalties gave birth to the PNG file format, TechRadar](https://www.techradar.com/pro/how-a-dispute-over-royalties-gave-birth-to-the-png-file-format)
13. [A Brief History of the GIF, Smithsonian Magazine](https://www.smithsonianmag.com/history/brief-history-gif-early-internet-innovation-ubiquitous-relic-180963543/)
14. [5 Gifs That Surprised Even the Gif's Inventor, TIME](https://time.com/2928183/gif-inventor/)
15. [Portable Network Graphics (PNG) Specification (Third Edition), W3C](https://www.w3.org/TR/png-3/)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026; Oct 25, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Data formats and serialization › Image and video formats

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/gif

English original: https://www.edgepedia.org/gif
