Home  >  Article  >  What is the file format of gif?

What is the file format of gif?

青灯夜游
青灯夜游Original
2020-12-29 13:57:16113898browse

gif is a bitmap graphics file format. GIF means "Image Interchange Format" in Chinese. It is a relatively commonly used dynamic image format that reproduces true-color images with 8-bit color (i.e. 256 colors). The gif format file is actually a compressed document that is encoded using the LZW compression algorithm, which can effectively reduce the time for image files to be transmitted on the network.

What is the file format of gif?

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

The full name of GIF is Graphics Interchange Format, which can be translated as Image Interchange Format. It is a bitmap graphics file format that reproduces true-color images with 8-bit colors (that is, 256 colors).

GIF is used to display indexed color images in the form of Hypertext Markup Language, and is widely used on the Internet and other online service systems.

It is actually a compressed document, encoded using the LZW compression algorithm, which effectively reduces the time for image files to be transmitted over the network. It is one of the most widely used network transmission image formats on the World Wide Web.

When Stephen Wilhite was working at Compuserve, he led the engineering team to invent the GIF file. With its small size and relatively clear image, it was very suitable for the early Internet environment with low bandwidth. Nowadays, Internet users use GIF files for creation and have become one of the formats used as Internet memes. Wilhite also won the Webby Award for Lifetime Achievement in 2013. As for how to pronounce "GIF", many people pronounce it with the sound of "gift", but when he corrected his name, he should pronounce it with the same sound as "Jif".

Most of the common small animations on the Internet are in GIF format, also called frame-by-frame animation, which is a picture that is composed of several pictures together (some are single frames). It uses lossless compression technology, which can reduce file size while maintaining imaging quality as long as the image does not exceed 256 colors. GIF is divided into two types: static GIF and animated GIF. The extension is .gif. It is a compressed bitmap format that supports transparent background images and is suitable for a variety of operating systems. It has a small "body size" and many small animations on the Internet are GIFs. Format.

GIF is a bitmap. The general principle of bitmap is: a picture is composed of many pixels, each pixel is assigned a color, and these pixels are combined to form a picture. GIF uses the Lempel-Zev-Welch (LZW) compression algorithm and supports up to 256 colors. Due to this characteristic, GIF is more suitable for pictures with less color, such as cartoon shapes, company logos, etc. If you encounter situations where true colors are needed, the expressive power of GIF will be limited. GIF usually comes with a palette that stores the various colors that need to be used. In web applications, the file size of images will obviously affect the download speed. Therefore, we can optimize the palette according to the characteristics of GIF with palette and reduce the number of colors used in the image (some images cannot use it. colors can be dropped) without affecting the quality of the picture.

The biggest difference between the GIF format and other image formats is that it is completely designed as a public standard. Due to the popularity of the Compu Serve network, many platforms support the GIF format. Compu Serve promotes GIF by distributing format instructions for free, but requires software that uses the GIF file format to include a description of its copyright information.

Features

The image file in GIF format has the following characteristics:

(1) The extension of the GIF format image file is ".gif".

(2) performs best for grayscale images.

(3) There are two versions: GIF87a and GIF89a.

(4) Use the improved LZW compression algorithm to process image data.

(5) Palette data is divided into general palette and local palette, with different color values.

(6) Does not support 24bit color mode, and can store up to 256 colors.

Technical Introduction

GIF is mainly a transmission format designed for data flow, rather than as a storage format for files. It has a sequential rather than a random organization.

GIF has five main parts that appear in a fixed order, and all parts are composed of one or more blocks. Each block is identified by an identification code or signature in the first byte. The order of these parts is: header block, logical screen description block, optional "global" color table block (palette), individual image data blocks (or dedicated blocks), and tail block (end code). Here's what these sections contain:

  • begins with a block that identifies the data stream as a GIF and indicates how to interpret the following data, which required the earliest version of the GIF decoder (87a or 89a).

  • The logic program description block defines: the size, aspect ratio, and color depth of the image plane for all subsequent images (which is similar to the monitor screen on which the image is produced). It also indicates whether what follows is a "global" colormap.

  • The global color table (if it exists) constitutes a palette of 24-bit RGB tuples (one byte for each background color). If the underlying image does not have its own "local" palette, the global color table is the default palette.

  • Subsequent data appears as "graphical" or "private" blocks. Graphics blocks typically contain one or more bitmap images, possibly overlaid with text. Private blocks either contain a private application code or a non-printable comment.

  • The last tail block indicates a byte with a value of 3B (hex), indicating that the data stream has ended.

Note: The GIF data stream in the file may not contain any bitmap data at all. In this case, it is just transmitting the global color table as subsequent data without its own palette. The default color palette for the stream.

The above is the detailed content of What is the file format of gif?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn