A1.1.9 — Compression

← Back to A1.1 overview

What is Compression?

Reducing file size to enable faster transmission over networks, less storage usage, and better application performance.

Lossless vs Lossy

FeatureLosslessLossy
Data integrityOriginal fully preserved — decompressed file is identical.Some data permanently discarded.
Compression ratioLowerHigher
Reversible?YesNo
Use caseBackups, documents, archives, source code.Images, audio, video — where minor quality loss is acceptable.
ExamplesGIF, TIFF, ZIP, PNG, PDFJPEG, MP3, MPEG

Compression Methods

Run-Length Encoding (RLE)

Replaces runs of consecutive identical values with a count and the value.

Example: AAAABBBBCC4A4B2C

Type: Lossless. Best for: Data with long repeated sequences — fax images, simple graphics, text files.

Transform Coding

Converts data into a different mathematical representation (e.g. Discrete Cosine Transform in JPEG) that makes redundancy easier to remove.

Type: Usually lossy. Best for: Complex data like photos, audio, video — achieves much higher compression ratios than RLE.

Used in: JPEG, MP3, MPEG.

File Formats Summary

TypeFormatsTypical use
LosslessPNG, GIF, TIFF, ZIP, PDFBackups, documents, simple graphics
LossyJPEG, MP3, MPEGPhotos, music, video
RLEFax format, BMP (uncompressed)Fax images, simple text
Transform codingJPEG, MP3, MPEGPhotos, audio, video