Graphics images on internet come in three major formats: GIF, JPEG and PNG (and PNG's close relation MNG). Each of these formats has it's associated advantages and disadvantages. It is important that you understand all three formats to make correct decision as to which to use under what circumstances.
One of major factors to consider when choosing or using a graphics format is size of resultant image file. In addition, you will need to understand how to optimize images in each format to be cognizant of results that you can gain.
What is image optimization? It is simply defined as finding correct compression settings to make image as small as possible with as little loss of resolution as you can get away with. Why is this necessary? Because it take time for images to be loaded (most people are accessing internet over dialup connections, after all) and optimization reduces that time.
The first and most primitive graphics format is known as BMP, which means bit mapped. These kinds of images may not be compressed as they are simply an exact description of what is to be shown on screen. Each pixel is represented by 3 bytes (red, blue and green), and each byte contains color intensity of it's base color. This BMP images can be made up of 16 million colors. BMP files tend to be very large, and you don't see them directly on web pages very often. Where you will find them is in collections of wallpapers (wallpapers in system directory must be in BMP format), desktop themes and similar things.Because BMP files were much too large for normal web browsing (especially several years ago when virtually every user was not only on a dialup connection, but was lucky to get 4800 or 9600 baud) other formats were invented. Two of these formats became dominant and are now found just about everywhere. These are GIF and JPEG images types. The formats are extremely different and have widely separate applications. Your average web site will generally include a mixture of both formats, as each has their use.
GIF was created by CompuServe in 1987 for their online service. GIF images consist of no more than 256 colors, because each pixel is represented by a single 8-bit byte. This means that in order to convert a BMP image to a GIF image you have to discard all but 256 colors at most!
Each GIF image has a description (known as a header) that defines colors that will be used in image. This allows colors to be assigned to a code which is what actually appears in image. Thus, header might say "red is color #47, bluegreen is color #48" and so on. Later in image, colors can be represented as "color #47 is used for next 546 pixels".
Thus optimization of GIF images is fairly straightforward and is handled by virtually every graphics program on market. For example, Paint Shop Pro allows you to export an optimized GIF image with a very cool wizard to help you choose exactly best options. Using optimizer it is possible to reduce an image file size by 95% or more! This means a 100k image can be reduced to 5k or less by this method of optimization.