True Color (24 bit): each pixel color is represented using 3 bytes, one for red, one for green, and one for blue. This is referred to RGB color. Since a single byte can represent 256 different shades, there are a total of roughly 16 million (256x256x256) colors that can be represented.
True Color (32bit): This is the same as 24 bit true color except that there is an extra byte, usually referred to as the alpha component, used to specify transparency.
16 bit Color: Each pixel is represented using 16 bits or 2 bytes. There are 5 bits for red, 6 bits for green, and 5 bits for blue. The total number of possible colors is about 65 thousand (256x256).
8 bit Color: Here, 256 different 24 bit colors are selected out of the 16 million possible. These 256 colors are called the palette. Each pixel is represented by a single byte. This byte is not the color but is the location of the color in the palette. When an image is stored, the 8 bit color location for each pixel is saved along with the palette. For a large image this can be significant space savings.
Images are represented by by specifying the color of each pixel using one of the above color formats. For large images, the storage space can be very large. As a result, images are usually compressed, meaning that redundancies are removed. For example, suppose a 100x100 pixel image in 24 bit true color happens to be all one color (not a particularly interesting picture). To store it requires 100x100x3 = 30,000 bytes. However, it can also be can be saved very efficiently by specifying the single color (3 bytes) and the size of the image. This format will take on the order of 10's of bytes instead of many thousands.
The following image formats correspond to different method of compressing files.
GIF: Assumes a palette of size 256 colors. If the image has more than 256 colors then there will be some loss of information (called lossy), otherwise, the image will be saved exactly (lossless). GIF allows for images to have transparency. This is useful if one wants the web page background color to show through (e.g. an edge can be faded out). Colors that are thrown out can be approximated using dithering. Dithering is a technique where two existing colors can be placed near each other to give the effect of a third color. Because of the color limit, gif is typically used for images that contain a limited number of colors.
JPEG: JPEG is a lossy format. Once can specify the amount of compression (and thus the amount of information loss) by setting a quality level. Unlike GIF, JPEG is not limited to 256 colors. When an image has many different colors such as in photographs of natural scenes, JPEG is the format of choice. JPEG, however, does not allow for transparency.
PNG: PNG is a more recent file format that is not supported by older browsers. PNG-24 uses 24 bit color, is lossless, and allows transparency. The size of the files can be considerably larger than JPEG. PNG-8 assumes a palette. Like GIF, if the image has a limited number of colors, the compression will be lossless and will be considerably smaller than PNG-24.
There are many other image formats such as Targa, PICT, BMP, .... However, these formats are not supported by any browsers.
For a summary of file formats (not just graphics) click here or here.
General Rule of Thumb: