This relatively new format is designed as a successor to GIF. Comparison of PNG and GIF formats.

Features common to both PNG and GIF formats :

Number of colors in an image: maximally 256.
Streamability: the file can be read and written in streams.
Progressive displaying: advantageous for communication lines where a picture can be displayed in stages in low-resolution with gradually growing details.
Transparency: some parts of the image can also be transparent?.
Auxiliary information: an image can contain text comments and other data.
Complete hardware and platform independence?.
Loss-free compression.

Important PNG features, lacking in the case of GIF :
Truecolor images maximally 48 bit per pixel.
Grayscale images maximally 16 bit per pixel.
Alpha channel has a transparent mask.
Image gamma indication, for instance automatic adjustment of brightness and of contrasts
Direct detection for a damaged file.
Faster initial displaying (view) in the progressive display mode.

The PNG is determined for the following :
Simplicity and portability: PNG can be relatively easily and widely implemented.
Legal use: No copyright is applied to the use of PNG algorithms or a PNG part.
Well compressed pictures: Also the pallet as well as the truecolor images are compressed as in other loss-free image compressions.
Universality: every part (level) of the PNG decoder can read the remaining levels of PNG files.
Flexibility: In the future the format allows for extension and add-ons, without a compromise in the universality of basic PNG.
Robust design supports full control of file integrity as well as simplicity and fast detection of possible errors in transmission. PNG format.

    This is intended for transmission of images through a network. Similarly as with the GIF, also it uses the LZW compression. It supports almost all color depths from 2 bytes to 32 bytes per point. For better data storage into a file it uses pre-processing of pixels. Pre-processing uses one of the following five methods:
The pixel is directly coded and stored
The difference of values with the pixel left is stored
The difference of values with the upper pixel is stored
The average value of the pixel and its neighbors left and up is stored .
The average value of the pixel and its neighbors left, up, and left up, is stored using the special algorithm.
Pixels pre-processed in this way are stored using the LWZ coding.

Picture : PNG file header, (16 Mil. farieb, 60x35 pixlov) PNG title.

Offset Size  Meaning
0-7  8 byte  Identification :  137 80 78 71 13 10 26 10

    Every PNG file contains just one part of IHDR and several IDAT sections. Image Header (IHDR).

4 bytes  Identification of IHDR 
4 bytes  Width of the image
4 bytes  Height of the image
1 byte  Bit depth  
1 byte  Color type 
1 byte  Compression type 
1 byte  Filter type 
1 byte  Sweep type  

    'Image width and height' - specify the dimensions of an image in pixels. They are represented by a 4-byte integer. Zero value is not allowed. The maximal value for each is: (2^31)-1, due to compatibility with the value of the last bit, which is used in some programming languages for identification of sign.

    'Bit depth' is represented by one byte, which determines the number of bits per one pixel (for images with a pallet) or a sample (for grayscale and true images). The permissible values are 1, 2, 4, 8, and 16, although not all values are allowed for all color types.

    'Color type' is a one-byte value describing interpretation of image data. It represents a sum of the following values: 1 (the pallet is used), 2 (color is used), 4 (used the full alpha). Permissible values: 0, 2, 3, 4, and 6.

    Bit depth limitations are specified for each color type for simplification of implementation and prohibit certain combinations, which in practice are not well compressed. The decoder must support every allowed combination of bit depth and color type. The following combinations are allowed:

Color type Bit depth Meaning
0 1,2,4,8,16 Every value of the pixel is a grayscale level.
2 8,16 KEvery value of the pixel is an R, G, B series.
3 1,2,4,8 Every value of the pixel is a pallet index.
4 8,16 Every value of the pixel is a grayscale level, followed by an alpha channel level.
6 8,16 Every value of the pixel is an R, G, B series, followed by an alpha channel level.

    Compression type (1 byte) indicates the compression method used for compression of image data. At present, only the type '0' is defined (deflate/inflate compression with 32K sliding window). All standard PNG images must be compressed using this type. The compression type supports the possible future expansion or variability of variants. The decoder must check this byte and report an error in the case on an unknown code (that is, if it contains a value other than 0).

    Filter type (1 byte) identifies the pre-processing method applied to image data before compression. At present, only one type of the filter '0' is defined (adaptive filtering with 5 basic types of filtering). As in the case of the compression type, the decoder must test this byte and report an error, if it contains an unknown code.

     Interlacing type (1 byte) identifies the transmission order of image elements. There are defined two values: '0' (not interlaced) and '1' (Adam7 interlaced). Image Data (IDAT)

    This section contains image data. 

PNG compression

    The PNG compression of the type 0 (at present it is only this type) specifies deflate/inflate compression with the 32 Kwindow. The deflate compression is LZ77, derived from zip, gzip, pkzip and similar programs. After extenive research, the C implementation is freely accessible. Documentation and C-code for decompression are accessible at the address:


The 2D interlacing scheme used in the PNG format is more complexly implemented than the line way of interlacing used in the GIF format. Though the file is afterwards a little bigger, the viewing of an image is 8-times faster than in the case of a GIF (for the first sight it is enough 1/64 image data as opposed to 1/8 in the case of a GIF). Although such a sight picture is rough, it is reasonable for a fast overview.  

You can find a source of more comprehensive information about the PNG at the address: