File compression simply means to reduce the actual size of the file when it is saved, or to put that slightly more technically to reduce the number of bits (1's and o's) used to store the information in the file. Compressed files take up less space on hard drives, but they are also require less bandwidth to transfer which makes them a major part of the internet.
There are two basic approaches to compression - Lossy and Lossless.
Lossy Compression works by getting rid of bits and hoping no-one notices. Using lossy compression removes some of the subtle differeces on the file - so for an image two pixels that are almost but not quite the same colour are made the same colour. For an audio file lossy removes sounds humans can't hear from the recording.
The more "heavy" the compression, the more data is removed and eventually this becomes noticeable and the quality falls off.
Common examples of Lossy compression include jpeg, mp3, mp4.
Lossless Compression is a way of reducing file size so that you can rebuild the original file. The lossless approach doesn’t throw any information out, instead, it removes redundancy - it stores the same information in a more efficient way.
Consider the following directions :
- left, left, left, right, right, left, left
- it would be more efficient to say : 3 left, 2 right, 2 left - it takes less space to store it too.
Common examples of Lossless compression include png, flac, avi.
- Lossy files are smaller
- Lossless files do not remove information (lossy do)
- Lossless files can be rebuilt to the original (lossy can't)