JPG Generation Loss: What Repeated Saving Does to an Image

November 08, 2026 · HENRICK HEILESEN · JPEG Troubleshooting

Explain quantization compounding, when loss occurs, lossless transforms and a safe editing workflow.

How Quantization Compounding Degrades JPEG Images Across Generations

Quantization Compounding: The Core Mechanism

Every JPEG save discards information through quantization. The encoder divides the image into 8×8 pixel blocks, transforms each block into frequency coefficients using the Discrete Cosine Transform (DCT, defined in ITU-T T.81 §3.3), then rounds each coefficient to a less precise value according to a quantization table. That rounding is the loss mechanism.

On the first save from a lossless source (RAW, PNG, TIFF), quantization removes detail the encoder judges imperceptible at the chosen quality setting. On the second save, the encoder treats the already-degraded image as a new source. It re-quantizes the same 8×8 blocks, but the frequency data is now an approximation of the original. Rounding errors from the first save do not cancel out—they compound. Each subsequent save rounds already-rounded coefficients again, and block boundaries become visible as the image drifts further from the original signal.

Observable check: Open the same JPEG after 1, 5, and 20 saves at a fixed quality setting (e.g., 85). Zoom to 400% on a smooth gradient area—sky, painted wall, studio backdrop. After 5 saves, faint horizontal and vertical grid lines appear at block boundaries. After 20 saves, the blocks separate into visible tiles, and flat areas develop a speckled texture resembling a dirty window.

Hard limit: Re-saving at higher quality (95–100) does not reverse accumulated damage. A tenth-generation JPEG saved at quality 100 is visually worse than a first-generation JPEG saved at quality 75. Quality settings control how aggressively a single quantization pass rounds coefficients; they do not restore coefficients already discarded in prior generations.

When Re-Encoding Occurs and When It Does Not

Not every edit triggers a full re-encode. Distinguishing lossless from lossy operations prevents unnecessary generations.

Operations that always re-encode image data:

  • Pixel-level edits: brightness, contrast, color balance, sharpening, noise reduction, resizing
  • Cropping to dimensions not aligned to the JPEG block grid (see below)
  • Converting color profiles (sRGB to Adobe RGB or vice versa) when the tool decodes and re-encodes pixel data
  • Re-saving after metadata-only edits in software that decodes the image stream regardless (common in consumer image editors)

Operations that can avoid re-encoding:

  • Rotating by 90°, 180°, or 270° (JPEG supports lossless rotation using block structure; see ITU-T T.81 Annex K)
  • Flipping horizontally or vertically (same block structure preservation)
  • Editing Exif, IPTC, or XMP metadata only, provided the tool writes metadata without touching the compressed pixel data
  • Removing or replacing the embedded thumbnail (stored separately from the main image stream)

Tool verification: Many applications claim lossless rotation but decode and re-encode the entire image. Test your tool: rotate a JPEG 90°, save, rotate it back, and compare pixel-by-pixel against the original using ImageMagick's compare command. If the images differ by even one pixel, the tool re-encoded.

Lossless Transforms: What the JPEG Standard Supports

JPEG's 8×8 block structure enables limited lossless operations that never touch the quantized DCT coefficients. The standard defines these under lossless operations in ITU-T T.81 Annex K:

  • Block-aligned cropping: Cropping to dimensions that are multiples of 8 (or 16 for chroma-subsampled images) preserves all untouched blocks exactly. A crop from 4000×3000 to 3984×2984—removing 16 pixels from each edge—is lossless. A crop to 3985×2985 is not; the extra row and column force a full re-encode of every block.
  • Transposition and reflection: 90°, 180°, and 270° rotation; horizontal and vertical flip. These operate by reordering existing 8×8 blocks and optionally transposing coefficients within each block. No re-quantization occurs.
  • Color space transform without re-encode: Some tools can change Y′CbCr subsampling (e.g., 4:2:2 to 4:4:4) losslessly, but this is rare in practice. Most applications downsample chroma channels during a full re-encode.

Practical limitation: Lossless transforms are only safe when the tool uses jpegtran (from the Independent JPEG Group's library) or a JPEG-aware library that calls block-level functions. Photoshop's "Save for Web" never performs lossless transforms. ImageMagick's -rotate does not by default; you must invoke jpegtran separately or use explicit JPEG-aware options.

A Workflow That Preserves Generations

When repeated editing of a JPEG source is necessary—retouching a client proof, building a composite from existing JPEG assets—the goal is to minimize the number of lossy encodes.

  1. Open the JPEG and immediately save as a lossless intermediate. Use PNG, TIFF with LZW compression, or a layered format such as PSD. This freezes the current generation as a pixel-exact copy. All subsequent edits operate on this lossless master.

  2. Edit the lossless master. Crop, adjust, retouch, composite. All operations are lossless because the intermediate format stores exact pixel values.

  3. Export to JPEG exactly once at the end. Use the highest quality setting that meets the file size requirement—typically 90–95 for web delivery, 95–100 for print. One encode, one quantization pass.

  4. If the exported JPEG requires further editing, return to the lossless master from step 1, not the exported JPEG. Never open a JPEG, edit, and re-save as JPEG when a lossless master exists.

Exception for metadata-only workflows: When editing only titles, captions, dates, or GPS coordinates, use a tool that writes metadata without touching the image stream. ExifTool with -overwrite_original preserves the compressed JPEG data exactly. Verify by running exiftool -all= -o test_copy.jpg original.jpg—if the file size is identical within a few bytes (accounting for the metadata block), the image data was untouched.

Failure Modes and What Cannot Be Recovered

  • Block boundary artifacts: Once quantization creates visible 8×8 grid lines, no filter or sharpening can remove them without introducing new artifacts. The grid is a structural property of the DCT coefficients themselves.
  • Chroma bleed: Heavy chroma subsampling (4:2:0) discards 75% of color resolution. Re-saving at 4:4:4 does not recover the missing color detail—the data was already discarded. The encoder re-encodes an approximation as if it were full-resolution color.
  • Flat area banding: Posterization in smooth gradients worsens with each generation because quantized DCT coefficients lose the subtle variations between adjacent blocks. Saving at higher bit depth (e.g., 16-bit TIFF) before the final JPEG export can prevent banding in the first generation but cannot repair banding already baked into the source JPEG.
  • Over-sharpening halos: If a previous generation applied sharpening, the halos—light and dark edges at contrast boundaries—are encoded as part of the image. Subsequent saves sharpen those halos further, creating white and black rims. No unsharp mask with negative values can remove halos already quantized into frequency data.

The only recovery path is to return to the original image source—RAW, camera JPEG, or lossless master—and start over. A JPEG is a terminal format. Once saved, every subsequent save is a degradation, not a preservation.