Compression/decompression

From WLCS

Compression

Compression (usually of data) is a method of maximising storage space on a disk, and can be done in a number of methods.

Lossless Compression

'Lossless' compression is usually favoured, and means that the data, after being compressed, can be perfectly restored to it's original value. Some examples of this are:

  • Removing leading/trailing whitespace characters
  • Finding patterns in data and replacing them with shorter codes
    • .zip, .tar.gz, and .7z all have different algorithms for this

Lossy Compression

'Lossy' compression means that the data, after being compressed, can not be restored to it's original quality and value. This happens when the data is simply trimmed and not shortened with patterns. An example of this are .mp3 music files, where the original track's quality cannot be restored because of the original sampling rate. This is generally unfavourable. While it does lower the size of the file on a disk, quality is compromised.

Decompression

Decompression deals with restoring data back to its original value after it has been compressed. If the file was not lossily compressed, the data can be made to match the original quality. However, if there was data loss in compressing the file, the data can never be properly restored unless an uncompressed copy of the original file is at hand.