ALL IN BASKETBALL ACADEMYScience & Technology

Reading room / Representation

Smaller files, complete information

A file can take up less space without losing its original information. Lossless compression changes how data is represented so that a decoder can reconstruct it exactly.

General educational information

Original informationCompact representationOriginal restored

Patterns make room

Repeated sequences offer an opportunity. Instead of writing the same value again and again, a format can describe the repetition. Other methods use dictionaries or shorter codes for frequently occurring patterns. The decoder needs the corresponding rules to reverse the transformation.

A hypothetical example

Imagine a row containing twelve identical gray pixels. An illustrative run-length representation could describe it as “gray, twelve times.” This is a teaching example, not an actual image-file format. A row of unrelated colors would offer less repetition to exploit.

A row of twelve identical squares represented by one square and a count of twelve.
Illustrative run-length representation, not a file-format specification.

Define what stays intact

Lossless image compression preserves the encoded image data. A wider optimization workflow may separately remove metadata, such as descriptive tags. Preserving the pixels and preserving every original file byte are different requirements. The word “lossless” needs that context.

A useful trade-off

Compression and decompression require computation. Results depend on the source material and method; a file that is already compressed may offer little further saving. Lossy compression makes a different trade-off by discarding some information. A visually similar result does not establish that the original data can be recovered. Ask what must survive, which program will decode it, and whether the result has actually become smaller.

Further reading: Adobe: file compression.