PNG is an image file storage format that was developed in the mid-1990s. Its purpose is to replace the GIF and TIFF file formats while adding some features that the GIF file format does not have. The Portable Network Graphic Format (PNG) name comes from the unofficial "PNG's Not GIF". It is a bitmap file storage format, pronounced "ping". When PNG is used to store grayscale images, the depth of the grayscale image can be up to 16 bits. When storing color images, the depth of the color image can be up to 48 bits, and it can also store up to 16 bits of alpha channel data. PNG uses a lossless data compression algorithm derived from LZ77.
The PNG file format retains the following features of the GIF file format:
Color images can support 256 colors using a color lookup table, or palette.
Streaming read/write performance (streamability): The image file format allows continuous reading and writing of image data. This feature is very suitable for generating and displaying images during the communication process.
Progressive display: This feature allows the image file to be transmitted on the communication link while simultaneously displaying the image on the terminal. After the entire outline is displayed, the details of the image are gradually displayed. It is to display the image with a low resolution first, and then gradually increase its resolution.
Transparency (transparency): This feature allows certain parts of the image not to be displayed, and is used to create some distinctive images.
Auxiliary information (ancillary information): This feature can be used to store some text annotation information in the image file.
Independent of the computer software and hardware environment.
Use lossless compression.
The following features that are not available in the GIF file format will be added to the PNG file format:
Each pixel is a 48-bit true color image.
Each pixel is a 16-bit grayscale image.
Alpha channels can be added to grayscale and true color images.
Add image gamma information.
Use cyclic redundancy code (CRC) to detect corrupted files.
Speed ??up the successive approximation display method of image display.
Standard read/write toolkit.
Multiple images can be stored in one file.
File structure
The PNG image format file (or data stream) consists of an 8-byte PNG file signature field and 3 fields organized according to a specific structure. It is composed of the above data chunks.
PNG defines two types of data chunks, one is called critical chunk (critical chunk), which is a standard data chunk, and the other is called auxiliary data chunk (ancillary chunks), which is an optional data block. Key data blocks define 4 standard data blocks. Each PNG file must contain them, and PNG reading and writing software must also support these data blocks. Although the PNG file specification does not require PNG codecs to encode and decode optional blocks, the specification promotes support for optional blocks.
Comparison with gif jpg
GIF image format: born in 1987, often used for web animation, uses lossless compression, supports 256 colors (generally called 8-bit color), and supports single transparency Color;
JPEG pictures (jpg for short): Born in 1992, photos generally use this format, lossy compression, 24 bit true color (224 = 170,000 colors), animation is not supported, and Transparent color;
PNG image format: Introduced in 1996, lossless compression, the most commonly used formats are 256 index color (PNG-8) and 24 bit true color (PNG-24) (of course PNG supports The color format is much more than that), supports full alpha channel (256 levels of adjustable translucency), and does not support animation.
A simple comparison of three image formats:
Comparison of JPEG and PNG format images: JPEG has huge advantages in photo compression and is irreplaceable in this regard, but JPEG is lossy compression , the picture quality will be lost. In addition, the PNG format is generally used for screenshots, which not only has higher quality than JPEG but also has a smaller file size.
Comparison of GIF and PNG format images: GIF only has advantages in the field of simple animations (in fact, GIF’s 256 color limit and lossless compression mechanism lead to the release of high-quality animations generally using formats such as Flash), as long as there is no Animation and PNG can completely replace GIF. In general, 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. It is suitable for a variety of operating systems. Its "body size" is small and there are many on the Internet. Small animations are all in GIF format. In fact, GIF saves multiple images into one image file to form an animation, so in the final analysis, GIF is still a picture file format. But GIF can only display 256 colors. Like the jpg format, this is a very popular graphics file format on the Internet. So generally the dynamic pictures we see on web pages are generally in GIF format.
In general, many small icons on the Internet use png as the image format. png is an image storage format that can be used directly as material because it has a very good feature: transparent background. When choosing what format to output when making pictures, the best output is mainly selected based on the characteristics of the picture format.