|
File formats are intended to store particular kinds of digital information: the JPEG format, for example, is designed only
to store still images, while the GIF format supports storage of both still images and simple animations. The most well-known
formats have file specifications that describe exactly how the data is to be encoded.
Since files are seen by programs as streams of data (0s and 1s), a method is required to determine the format of a particular
file within the file system. One popular method is to determine the format based on the final portion of the filename, known
as the filename extension.
The standard greyscale images use 256 shades of grey from 0 (black) to 255 (white).
With color images, the situation is more complex. For a given number of pixels, considerably more data is required to represent
the image and more than one color model is used.
We will consider the following data format:
GIF uses lossless LZW compression for relatively small file sizes, as compared to uncompressed data. GIF files offer optimum compression (smallest files) for solid color graphics, because objects of one exact color compress very efficiently in LZW. The LZW compression is lossless, but of course, the conversion to only 256 colors may be a great loss.
The GIF format can only show 256 colors but it can choose any of the 16 million colors in a 24-bit image.
8 bit = 256 colors
7 bit = 128 colors
6 bit = 64 colors
5 bit = 32 colors
4 bit = 16 colors
3 bit = 8 colors
2 bit = 4 colors
1 bit = 2 colors (usually B/W)
GIF optionally offers transparent backgrounds, where one palette color is declared transparent, so that the background can show through it.
TIFF files have many formats: Black and white, greyscale, 4- and 8-bit color, full color (24-bit) images. TIFF files support the use of data compression using LZW and other compression standards.
B/W Bitmap is monochrome and the color table contains two entries. Each bit in the bitmap array represents a pixel. If the
bit is clear, the pixel is displayed with the color of the first entry in the color table. If the bit is set, the pixel has
the color of the second entry in the table.
4-bit Bitmap has a maximum of 16 colors. Each pixel in the bitmap is represented by a 4-bit index into the color table array.
The first pixel contains the color in the second table entry, and the second pixel contains the color in the sixteenth table
entry.
8-bit Bitmap has a maximum of 256 colors. Each pixel in the bitmap is represented by a 1-byte index into the color table.
24-bit Bitmap has a maximum of 2^24 colors. Each pixel is a 3-byte sequence in the bitmap array represents the relative intensities
of red, green, and blue.
A JPEG image provides very good compression, but does not uncompress exactly as it was; JPEG is a lossy compression techniques.
Compressions up to 50:1 are easily obtainable.
The PNG format was designed to replace the antiquated GIF format, and to some extent, the TIFF format. It utilizes lossless compression. It is a universal format that is recognized by the World Wide Web consortium, and supported by modern web browsers.
Here are some representative file sizes for 1943 x 1702 pixels image (24-bit RGB), which can give you an idea of file sizes:
File type | File size | Description |
---|---|---|
TIFF | 9.9 MB | |
TIFF LZW | 8.4 MB | |
PNG | 6.5 MB | PNG files are about 25% small then TIFF and about 10% to 30% smaller than GIF files for indexed data. |
JPEG | 1.0 MB | The JPEG format compresses the picture every time it is saved and that means the file size is reduced every time it is saved. |
BMP | 9.9 MB |
The table below represents different compression rates of the same techniques. Also in this case you can see the differences in file sizes.
No compression 71 KB | 50% 38 KB | 99% 5 KB |
B/W no compression 16 KB |
No compression 2592 KB | LWZ compression 2154 KB | Huffman conding 206 KB |