English ▼

Lossless Compression

Having covered lossy compression it is time to look at lossless compression, which is an important compression mode used to reduce the size of our files without any loss in quality or data. This means that, once saved in a lossless format, the original file can be reconstructed identically, byte-for-byte. There are several lossless compression algorithms that have been developed over the years, with the two most popular being Huffman coding and arithmetic coding.

There are many file formats that implement lossless compression; two of the more popular formats include the image file format PNG and the general-purpose compressed container format ZIP. These are both well-known formats and achieve great compression results while maintaining the identical content of the original file.

Certain compression methods rely on the data being compressed to be of a certain type; for example, if you have an image that uses 256 unique colors or less, saving it to the PNG format can take advantage of this by creating a palette of the colors in use and packing the pixels into a byte-sized index. A single computer byte can store a number in the range of 0-255, which is where the previously mentioned 256 color limit comes from. PNG also supports the deflate compression algorithm, which further reduces the file size. This is because the data structure of indexed images is a perfect candidate for use in conjunction with the deflate algorithm.

A screenshot from a tank-based video game

A screenshot from a tank-based video game

A raster file from an old Acorn Archimedes computer

A raster file from an old Acorn Archimedes computer

A video game raster image saved as a PNG

A video game raster image saved as a PNG

Lossless compression algorithms do not work with all data types; for example, trying to compress certain files using the ZIP format may not result in any file size savings and may even lead to the compressed ZIP file being larger than the original file.

Some examples of files that compress really well are human-readable text files, source code, and binary files that contain predicable and repeating patterns of data. For more information on lossless compression, please see this article.

© 2024 ImageToStl. Convert your PNG and JPG Files to 3D STL files.

Your files are ready to download!