Image compression
Lossless compression
This project was born with the release of the excellent QOI format. Its simplicity and performance piqued my curiosity and made me ask myself the following questions:
- can the compression ratio of QOI be improved while maintaining a good level of performance?
- what are the other lossless image compression formats/codecs and what is their compression ratio/duration?
Main formats currently available:
Benchmark
Let's take the iconic image of this field, Lena...
... and let's try compressing it with the default settings of the following compressors:
| Format | File size (Ko) | Compression time (seconds) |
|---|---|---|
| PPM (uncompressed) | 769 | 0 |
| QOI | 712 | 0.15 |
| PNG | 464 | 0.37 |
| WEBP (lossless) | 418 | 1.0 |
| JPEG XL (lossless) | 416 | 1.5 |
| FLIF | 422 | 1.9 |
| PAQ | 382 | 147.0 |
These figures clearly illustrate the trade-off that compressors must make, depending on whether they aim to minimize:
- the size of the resulting file (PAQ)
- compression time (QOI)
Project timeline
This type of project has no end: if its initial objective was to improve the compression ratio of QOI, the temptation to compete with other compressors is too great... and there is always a better compressor (at least until PAQ)!
Along the way, I had the opportunity to learn more about:
- entropy encoders, in particular ANS by Jarek Duda.
- the 1001 ways to assemble the bits and logarithms that represent the pixels of each color channel to limit the number of bytes to compress (even if some are counterproductive and have a negative effect on the entropy encoder)
- the impact of context (close proximity) on the encoding of each pixel
- the integration of machine learning techniques and their impact on runtime performance
I am currently focusing on compressing photographs (or medical/satellite images...). Compressing icons, pictograms, or screenshots requires a different approach: limited number of colors, high degree of pixel/pattern repetition.
Progression
My goal is to approach or exceed the compression rates of JXL / FLIF / WEBP and the compression time of PNG.
I will update this page as the project progresses.
This project does not have a dedicated forum. Requests and other feedback can be directed to [email protected].