From pixels to coefficients
An encoder reads a grid of pixels and writes a stream of numbers. Between those two states sit five stages, and only one of them destroys information.
A pixel grid is a terrible format for storage. Neighbouring pixels are almost identical, so the raw representation repeats itself endlessly. Compression works by translating the picture into a basis where that redundancy is explicit — usually a frequency basis, where smooth areas produce one large number and dozens of near-zero ones.
What the decoder can undo
Four of the five stages are exactly reversible: the colour transform, the block transform, the entropy decoder and the container framing. Quantisation is not. Once a coefficient is rounded, the decoder has no way to know what it was — it only knows what it became. Every visible artefact traces back to that rounding.