The Mathematics of JPEG Block Quantization
When an image is compressed into JPEG format, the image data is segmented into non-overlapping grid blocks of 8 × 8 pixels. Each 64-pixel block undergoes a 2D Discrete Cosine Transform (DCT) that separates the block into frequency components:
- DC Coefficient (Top-Left): The average baseline brightness and hue of the block.
- AC Coefficients (Higher Frequencies): Fine edge details, text sharpness, and micro-textures.
Why Aggressive Compression Creates "Blocky" Artifacts
To achieve very low file sizes (e.g. 15 KB), the compression engine applies a coarse Quantization Matrix that zeros out almost all high-frequency AC coefficients. The result is that subtle details disappear, and each 8x8 block is rendered as a flat or muddy gradient. At block boundaries, sharp discontinuities appear — known as blocking artifacts or ringing halos.
The Golden Secret: Resize Dimensions Before Compressing Quality
If you have a 3000 × 4000 pixel smartphone photo (12 MP) and force the compressor to squeeze it into 30 KB at full resolution, the algorithm is forced to discard 98% of frequency data, leaving a heavily pixelated, unrecognizable smudge.
Downsample the image resolution to the exact display dimensions needed (e.g. 600 × 800 pixels) first. At 600x800, there are only 480,000 pixels. Compressing 480k pixels to 30 KB only requires mild quantization, leaving facial features, eye contours, and signatures perfectly sharp and readable!