Menu

Compression

Lossless Compression

Lossless compression reduces a file's size without permanently removing any data. Nothing is thrown away, so when the file is decompressed every byte is restored and you get a copy identical to the original.

That makes it the right choice for text, program code and any other data where exact reconstruction matters. Change one character in a program and it may stop working; change one character in a text file and its meaning can change. Lossless compression carries no such risk because the data is stored more cleverly, not discarded.

It works well on files that contain repeated data or patterns. An attendance file might repeat the same class name on dozens of rows, and lossless compression can record that repetition in a shorter form instead of writing it out in full every time. Decompression then rebuilds the complete file exactly.

A compression ratio compares the compressed size with the original size. Lossless compression usually gives a lower ratio than lossy compression. The file still gets smaller, but often not as much, because the method must keep enough information to rebuild the original perfectly.

So the choice depends on the data and whether exact reconstruction is needed. When it is, use lossless compression; when a small, unnoticed loss is acceptable, lossy compression can shrink the file much further, but its original can never be recreated exactly.

Practise this