You should be aware of a few key factors... 

First, there are two types of compression: [Lossless][1] and [Lossy][2]. 

**Lossless** means that the image is made smaller, but at no detriment to the quality. **Lossy** means the image is made (even) smaller, but at a detriment to the quality. If you saved an image in a Lossy format over and over, the image quality would get progressively worse and worse.

There are also different colour depths (palettes): [Indexed color][3] and [Direct color][4]. 

With **Indexed** it means that the image can only store a limited number of colours (usually 256) that are chosen by the image author, with **Direct** it means that you can store many thousands of colours that have not been chosen by the author.


----------


**BMP** - Lossless / Indexed and Direct  

This is an old format. It is Lossless (no image data is lost on save) but there's also little to no compression at all, meaning saving as BMP results in VERY large file sizes. It can have palettes of both Indexed and Direct, but that's a small consolation. The file sizes are so unnecessarily large that nobody ever really uses this format.

Good for: Nothing really. There isn't anything BMP excels at, or isn't done better by other formats.

![BMP vs GIF][5]


----------


**GIF** - Lossless / Indexed only  

GIF uses lossless compression, meaning that you can save the image over and over and never lose any data. The file sizes are much smaller than BMP, because good compression is actually used, but it can only store an Indexed palette. This means that [for most use cases][6], there can only be a maximum of 256 different colours in the file. That sounds like quite a small amount, and it is.

GIF images can also be animated and have transparency.

Good for: Logos, line drawings, and other simple images that need to be small. Only really used for websites.

![GIF vs JPEG][7]


----------


**JPEG** - Lossy / Direct    

JPEGs images were designed to make detailed photographic images as small as possible by removing information that the human eye won't notice. As a result it's a Lossy format, and saving the same file over and over will result in more data being lost over time. It has a palette of thousands of colours and so is great for photographs, but the lossy compression means it's bad for logos and line drawings: Not only will they look fuzzy, but such images will also have a larger file-size compared to GIFs!

Good for: Photographs. Also, gradients.

![JPEG vs GIF][8]


----------


**PNG-8** - Lossless / Indexed   

PNG is a newer format, and PNG-8 (the indexed version of PNG) is really a good replacement for GIFs. Sadly, however, it has a few drawbacks: Firstly it cannot support animation like GIF can (well it can, but only Firefox seems to support it, unlike GIF animation which is supported by every browser). Secondly it has some support issues with older browsers like IE6. Thirdly, important software like Photoshop have very poor implementation of the format. (Damn you, Adobe!) PNG-8 can only store 256 colours, like GIFs.

Good for: The main thing that PNG-8 does better than GIFs is having support for Alpha Transparency.

![PNG-8 vs GIF][9]

**Important Note:** Photoshop does not support Alpha Transparency for PNG-8 files. (Damn you, Photoshop!) There are ways to convert Photoshop PNG-24 to PNG-8 files while retaining their transparency, though. One method is [PNGQuant][10], another is to save your files with [Fireworks][11].

----------

**PNG-24** - Lossless / Direct

PNG-24 is a great format that combines Lossless encoding with Direct color (thousands of colours, just like JPEG). It's very much like BMP in that regard, except that PNG actually compresses images, so it results in much smaller files. Unfortunately PNG-24 files will still be much bigger than JPEGs, GIFs and PNG-8s, so you still need to consider if you really want to use one.

Even though PNG-24s allow thousands of colours while having compression, they are not intended to replace JPEG images. A photograph saved as a PNG-24 will likely be at least 5 times larger than a equivalent JPEG image, with very little improvement in visible quality. (Of course, this may be a desirable outcome if you're not concerned about filesize, and want to get the best quality image you can.)

Just like PNG-8, PNG-24 supports alpha-transparency, too.


----------

**SVG** - Lossless / Indexed

SVG is a very unusual graphics format compared to the rest, as it can be created in a text editor. It's also unusual because it's the only format here that is Vector instead of Raster. With Vector images you can zoom in all you want, and it will never get pixelated. This is because, instead of the image saying, "colour the first pixel red, the second pixel blue, the third yellow", etc. SVGs say, "this is a circle filled with blue, this is a curve in red, this is a straight line in green". When you zoom in, you're just zooming in on a curve, not a pixel.

Because of this, SVGs are great for simple shapes, like icons, to be used on Retina displays, and especially shapes like you wish to animate based on user input (like graphs, for example).

W3Schools has a bad reputation, but I'm going to link to a very simple SVG example to show you how simple and effective they can be:

http://www.w3schools.com/svg/tryit.asp?filename=trysvg_ellipses

SVGs are very tricky to work with, so most people just find using a traditional raster format (like PNG or GIF) works well enough. If you wish to do advanced animations on your site, that can change on use input, then SVGs are perfect.



I hope that helps!


  [1]: http://en.wikipedia.org/wiki/Lossless_data_compression
  [2]: http://en.wikipedia.org/wiki/Lossy_compression
  [3]: http://en.wikipedia.org/wiki/Indexed_color
  [4]: http://en.wikipedia.org/wiki/Color_depth#16-bit_direct_color
  [5]: https://i.sstatic.net/J1EEX.png
  [6]: http://webmasters.stackexchange.com/a/39904/7654
  [7]: https://i.sstatic.net/F7VtM.png
  [8]: https://i.sstatic.net/aNqf7.png
  [9]: https://i.sstatic.net/B09oZ.png
  [10]: http://pngquant.org
  [11]: http://www.adobe.com/uk/products/fireworks.html