GIF, JPEG, and PNG are the three most common image formats.
- GIF: It was born in 1987 and is often used in Webpage animation. It adopts lossless compression and supports 256 colors (generally 8 bit color). It supports a single transparent color;
- JPEG: Born in 1992, the photo is generally in this format, lossy compression, 24-bit real color (224 = 0.17 million colors), does not support animation, does not support transparent color;
- PNG: released in 1996, lossless compression, the most common use format is 256 index color (PNG-8) and 24 bit true color (PNG-24) (of course PNG supports a color format far more than this ), supports full Alpha channels (256-level adjustable translucent colors) and animation is not supported.
Simple comparison:
- JPEG v. S. PNG: JPEG has a huge advantage in photo compression, Which is irreplaceable. However, JPEG is lossy compression, causing loss of image quality. In addition, the PNG format is generally used for screen screenshots, which is not only higher than JPEG quality, but also smaller in size (Wiki images ).
- GIF v. s. PNG: GIF has advantages only in the field of simple animation (in fact, GIF 256 colors and lossless compression mechanisms lead to the release of high-quality animation generally use flash and other formats), as long as there is no animation, PNG can replace GIF.
- Anti-aliasing: The following is a comparison between GIF and PNG anti-aliasing processing. The six pictures are placed in the light yellow and dark green backgrounds, and the three pictures are enlarged in the dark green background. Because GIF is not translucent, it can only be assumed that the background is white when it is anti-sawtooth. Therefore, it is better to put such a GIF on a dark background without anti-sawtooth. While PNG images can easily cope with various background colors, which are especially suitable for webpage and applications.ProgramThe general anti-sawtooth icon in can adapt to different skins. JPEG and GIF without full Alpha channels cannot do this.
We can see that, apart from photos and animations, PNG is the best format, but why has it become popular in recent years? There are many reasons:
- when PNG was born, the Internet had begun to take shape. At that time, GIF and JPEG were already very popular formats, and the cost of format-based migration was very high, sometimes inertia is a terrible thing.
- the PNG support of the browser is relatively backward. For example, ie only supports PNG from ie4.
- PNG originally written the alpha channel as optional, and the IE of the local turtle started to support the full alpha channel until IE7. Generally, the 256 color of webpage icons is sufficient. Therefore, in order to support IE6, PNG has no advantage over GIF, not to mention GIF supports animation.
- although, in principle, PNG images of the same quality are generally smaller than GIF images, many early image editors do not support PNG images, even PNG compression is not fully supported. The most subtle part of the algorithm (the most typical example is the early Photoshop ), the saved PNG is often huge. The current software has no such problems, but this prejudice still exists widely.