PNG files almost always offer better compression and a reduced file size compared to GIF. The PNG format also supports variable transparency and millions of colors while GIF only supports 256 colors and does not offer alpha channels. For online use, the only scenario where GIF files are appropriate instead of PNG is animations.
|Support for animation||Yes||No|
|Color management||No||Supports color management through the inclusion of ICC color space profiles|
|Support for multi-page||Yes||No|
|Support for transparency||Yes||Yes|
|File extensions||.gif, .gfa||.png|
|Indexed color||Yes||Yes (for 1-8bit PNGs)|
|Stands for||Graphics Interchange Format||Portable Network Graphics|
|Support for metadata||Yes||Yes|
|Support for layers||Yes||No|
|Type of format||Raster graphics image format||Raster graphics image format|
|Applications compatible||Most web browsers and productivity suites||Most web browsers and productivity suites|
|Compression algorithm||Lempel-Ziv-Welch (LZW)||Lossless DEFLATE compression algorithm|
|Uniform Type Identifier||com.compuserve.gif||public.png|
|Magic Number||GIF87a/GIF89a||89 50 4e 47 0d 0a 1a 0a|
Unless your image is animated, use the PNG format.
Advantages of PNG over GIF
The PNG format offers several advantages over GIF files:
- Better compression, resulting in reduced file size (typically 5 - 25% better)
- PNG supports variable transparency (alpha channels).
- PNG offers control of image brightness (via cross-platform gamma correction) and color correction.
- PNG supports two-dimensional interlacing (a method of progressive display) while GIF does not.
In a GIF file, only one color may be specified as transparent. GIF files end up producing halo effects when they used against background colors that are different from its assumed (usually white or black) background color.
PNG file have stronger transparency support, with an 8-bit alpha mask.