Yes I did that in this post, gif, jpg and png are "web" formats or compresed images, when you compress images you remove information from the image, people dont see the loss of data unless you compress them too much, like in jpg's some times you see squares in the image or edges become fussy.
The reason is that the human brain focus more on the difference in light and shadow then color, so when you compress images you remove color information and that reduces the file size.
There is to it then just that, here is some info on the formats
http://www.jpeg.org/
http://256.com/gray/docs/gifspecs/
http://www.libpng.org/pub/png/