How Image Compression Works (And How to Reverse It)
Image compression shrinks a file either by finding repetition it can describe more briefly (lossless, as in PNG) or by discarding detail the human eye is least sensitive to (lossy, as in JPG). Lossless compression is fully reversible. Lossy compression is not: the discarded information is gone from the file permanently.
What PNG does
PNG first applies a per-row filter that stores the difference between each pixel and its neighbour rather than the pixel itself, which turns smooth gradients into long runs of near-zero values. Those runs are then compressed with DEFLATE, the same algorithm behind ZIP. Nothing is thrown away, so decoding returns the exact original pixels. This is why PNG is the right format for screenshots, diagrams and anything with text or hard edges — and why photographs stay large in it.
What JPG does
JPG splits the image into 8×8 blocks and converts each to frequency coefficients with a discrete cosine transform. Low frequencies describe broad tone, high frequencies describe fine detail. The quantisation step then divides those coefficients by a table of values and rounds the result, which sends most high-frequency coefficients to zero. Zeros compress to almost nothing, and that is where the savings come from.
The quality slider scales that table. At quality 90 the divisors are small and little is lost; at quality 40 they are large and whole blocks of fine detail round away to nothing. Rounding is the step that cannot be undone — once a coefficient is zero, nothing records what it used to be.
Why "decompression" cannot restore it
Opening a JPG decompresses it back to pixels, but those pixels are reconstructed from the coefficients that survived. The visible artefacts of heavy compression — blocky 8×8 squares, coloured fringes around text, banding in skies — are what the surviving coefficients describe. Re-saving at a higher quality preserves the artefacts faithfully in a larger file.
AI upscalers can plausibly invent detail that looks convincing, and for a print or a display that can be useful. It is invention, not recovery, and it should not be relied on where accuracy matters, such as a document being read for its content.
Making a compressed file larger
If the requirement is a byte count rather than genuine detail, padding the file sidesteps the whole question. It adds bytes in places the decoder skips, which leaves the compressed image data exactly as it was. That is what the tool on this site does by default.
Need a file at an exact size?
The tool on this site sets a JPG, PNG or PDF to any target in KB or MB, in your browser, with no upload.
Open the tool