Entropy coding
The final, lossless stage of image compression — squeezing out the last bits by representing common values more compactly.
Definition
Entropy coding is a lossless compression step that represents frequently occurring values with short codes and rare values with long ones. It's the last stage of most image codecs: PNG's DEFLATE, JPEG's Huffman tables, and the arithmetic/ANS coding in AV1 and WebP. Because it's lossless, re-encoding it more aggressively can only help.
In practice
This is what a PNG optimizer like OxiPNG attacks: it re-runs entropy coding with stronger settings and better filters to produce a mathematically identical but smaller file. It's why \"lossless optimization\" is real and why two PNGs of the same pixels can have different file sizes.
This is lossless compression in action: a mathematically identical file, produced by better entropy coding and filters.
The idea, explained plainly
Entropy coding is easier to grasp through a postal analogy than through information theory.
Suppose you must send thousands of letters and 90% of them go to one address. Writing the full address on every envelope wastes space. Instead, agree in advance that a short mark means that address, and reserve longer marks for the rare destinations. Total characters sent drops sharply, and nothing is lost — the recipient still knows exactly where each letter goes.
Entropy coding does this with numbers. It builds a table mapping each value to a code whose length depends on how often that value appears, then writes only the codes. Frequent values get short codes; rare ones get long codes. The decoder reads the same table and reconstructs the original exactly.
Why it matters to you
This stage is why "lossless optimisation" is a real, honest claim rather than a contradiction — and why it has a hard ceiling.
Because entropy coding only changes representation, a tool can redo it more thoroughly than your original encoder did and produce a smaller file with pixel-identical output. Encoders are frequently conservative here: they pick a safe default table and move on, leaving measurable slack. A determined optimiser will search for a better table and find it.
The ceiling is set by the data itself. Entropy coding cannot invent compression where there is no statistical structure — random noise has none, and no amount of cleverness will shrink it. This is exactly why a photographic PNG barely improves while a screenshot improves a lot, and why running a second optimiser over an already-optimised file achieves nothing.
Related guides
Compress your images now — free and private
Process up to 200 images locally. Choose a format, compare the results and download a ZIP.