Effects of Repeated JPEG Quantization
Repeatedly saving a JPEG file triggers a cumulative degradation process known as generation loss, driven primarily by repeated quantization. Each time an image is opened, modified, and re-saved as a JPEG, the mathematical rounding of image frequency data introduces permanent errors. This article explains how quantization works during compression, the visual artifacts that emerge over successive saves, and why the rate of degradation changes depending on your workflow settings.
How Quantization Works in JPEG Compression
JPEG compression relies on the Discrete Cosine Transform (DCT) to convert spatial pixel data into frequency components. Human vision is far more sensitive to subtle variations in broad areas (low frequencies) than to rapid changes in fine detail (high frequencies).
Quantization is the lossy stage of this process:
- The 8x8 pixel blocks transformed by DCT produce frequency coefficients.
- These coefficients are divided by values defined in a quantization table.
- The resulting values are rounded to the nearest integer.
- Higher-frequency values, often reduced to zero, are discarded during entropy encoding.
Because rounding is mathematically irreversible, the discarded data cannot be recovered when the file is decompressed for viewing.
What Happens During Repeated Quantization
When you open a JPEG, edit it, and save it again, the software decompresses the image into raw RGB pixels and then re-applies the compression algorithm. This leads to several compounding effects:
1. Cumulative Rounding Errors
When the reconstructed pixels are converted back into frequency coefficients, the values rarely match the original numbers precisely. Re-dividing and re-rounding these slightly shifted numbers drops additional data with each cycle, compounding errors across the image.
2. Visible Image Artifacts
As quantization repeats, specific visual flaws become increasingly severe:
- Blocking Artifacts: The boundaries between the 8x8 DCT grid blocks become sharply defined, creating a noticeable checkerboard pattern.
- Ringing and Halos: Sharp edges between contrasting colors develop noisy, blurred halos (also known as Gibbs phenomenon).
- Color Banding (Posterization): Smooth gradients, such as clear skies, lose their subtle transitions and collapse into distinct, flat bands of color.
- Texture Flattening: Fine details like hair, foliage, and fabric weave are smoothed out as high-frequency information is progressively erased.
3. Degradation Under Identical Settings
If an unedited JPEG is repeatedly saved using the exact same software, compression level, and quantization table, the degradation does not continue indefinitely. After several iterations, the coefficient values stabilize—meaning dividing by the same matrix and rounding yields the same integers. At this point, generational loss levels off, provided the 8x8 grid alignment has not changed.
4. Severe Loss Under Changed Settings or Cropping
Degradation accelerates drastically if parameters change between saves:
- Altering Quality Levels: Switching quality levels applies different quantization matrices, recalculating rounding thresholds and stripping new data each time.
- Grid Misalignment (Cropping or Resizing): If an image is cropped by an offset that is not a multiple of 8 or 16 pixels, the 8x8 DCT block boundaries shift. Frequencies must be recalculated across completely new pixel groupings, restarting the degradation process at maximum intensity.
How to Prevent Quantization Loss
To avoid generation loss, keep images in a lossless working format—such as PNG, TIFF, or native project formats like PSD—throughout the editing process. JPEG should only be used as a final export format once all modifications and resizing are complete. For operations that only require rotation, cropping, or metadata updates, specialized lossless JPEG tools can manipulate the underlying DCT blocks without re-quantizing the image.