Skip to content

JPEG Compression Artefacts and Double-Compression Detection

JPEG is the dominant image format in forensic casework, and its compression process leaves a distinctive statistical fingerprint that manipulation disturbs. This topic covers DCT block structure, quantisation tables as a camera fingerprint, double-JPEG detection, and the JPEG ghost method for localising pasted regions.

Last updated:

Share

JPEG compression stores image data as quantised DCT coefficients within non-overlapping 8x8 pixel blocks, and this structure leaves a deterministic statistical fingerprint at every stage of encoding. When a JPEG is decoded, edited, and re-saved, a second round of quantisation acts on already-rounded coefficients, producing periodic peaks in the DCT coefficient histograms that are absent in singly-compressed images. The JPEG ghost method extends this principle to spatial localisation: by re-saving the image at multiple quality levels and mapping per-pixel error, regions with a different compression history reveal themselves at a characteristic quality offset. Quantisation tables, histogram periodicity, and block-phase analysis together give investigators three independent and convergent methods for detecting JPEG-based manipulation.

The overwhelming majority of digital photographs in forensic casework are JPEG files, because JPEG is the default format of virtually every consumer camera, smartphone, and social media platform. That ubiquity is forensically significant: the JPEG compression process is well-understood, deterministic, and leaves a statistical fingerprint at every step. When a JPEG is edited and re-saved, those fingerprints are disturbed in predictable, detectable ways.

The mechanism starts with the discrete cosine transform. JPEG tiles the image into 8x8 pixel blocks, converts each block from pixel values to frequency coefficients, and then quantises those coefficients, rounding them to coarser values according to a table that varies with the chosen quality level. The quantisation step is what throws information away and what makes JPEG lossy. It is also the step that records the quality setting and the table used, which varies between camera manufacturers and software packages like Photoshop, GIMP, or Instagram's pipeline.

When a JPEG is edited and re-saved, the image passes through quantisation twice, and the second quantisation acts on values that are already constrained by the first. The resulting coefficient histograms have a different shape than those of a singly-compressed image. Methods published by Popescu and Farid in 2004 and refined by Bianchi and Piva in 2012 formalised this observation into workable detection algorithms. The sections below build that machinery, then cover the JPEG ghost method, which localises pasted regions by their inconsistent compression history.

By the end of this topic you will be able to:

  • Explain the JPEG encoding pipeline (colour-space conversion, 8x8 block tiling, DCT, quantisation, entropy coding) and identify which steps are reversible and which are lossy.
  • Extract and interpret quantisation tables from a JPEG file header, and reason about what a table mismatch or per-region table inconsistency implies for image authenticity.
  • Describe the statistical mechanism by which double JPEG compression produces periodic DCT coefficient histograms, and identify the scenarios (same-quality re-save, Q1 > Q2) where the signal is suppressed.
  • Apply the JPEG ghost method to localise a suspect region, and articulate its limitations when source and host quality settings are close.
  • Interpret a block-phase shift at a spatial boundary as evidence of splicing and explain why the method remains effective when JPEG ghost analysis fails.
Key terms
DCT (Discrete Cosine Transform)
The mathematical transformation applied to each 8x8 pixel block during JPEG compression, converting spatial pixel values into a set of frequency coefficients from low (smooth) to high (detail).
Quantisation table
A matrix of divisors applied to DCT coefficients during JPEG compression. Higher divisors produce lower quality. The specific table used is often a manufacturer's or software's proprietary fingerprint.
Double-JPEG compression
The result of decoding a JPEG, applying any edit, and saving as JPEG again. The coefficient histograms of doubly-compressed images have a distinct periodic shape that singly-compressed images lack.
JPEG ghost
A localisation method that re-saves the image at multiple quality levels, then maps per-pixel residuals to find regions whose minimum error quality differs from the surrounding image, identifying pasted content with a different compression history.
Blocking artefacts
Visible rectangular discontinuities at 8x8 block boundaries, caused by independent quantisation of adjacent blocks. At splice boundaries, misaligned block grids produce a detectable phase shift.
Quality factor
The 1-100 scale that most JPEG encoders expose to the user, controlling how aggressively the quantisation table rounds coefficients. The factor is usually stored in the file header alongside the table itself.

How JPEG compression works

JPEG compression follows a fixed pipeline. First, the image is optionally converted from RGB to YCbCr colour space, separating luminance (Y) from two chrominance channels (Cb, Cr). The human eye is more sensitive to luminance detail than colour detail, so the chrominance channels are often downsampled. Then the luminance and chrominance channels are each divided into non-overlapping 8x8 pixel blocks.

RGB imageYCbCr +downsample8x8 blocktilingDCT per blockQuantisation(lossy)fingerprint here
JPEG compression pipeline with forensic trace points.

The DCT converts each 8x8 block into 64 frequency coefficients. The top-left coefficient (called DC) represents the block's average brightness. The remaining 63 coefficients (called AC) represent progressively finer spatial detail. These coefficients are then divided by the values in the quantisation table and rounded to integers. The table values for high-frequency entries are large, so fine detail is rounded aggressively, which is where the image quality loss occurs. The rounded coefficients are finally passed through entropy coding (Huffman or arithmetic), which is lossless.

When the file is decoded, the process reverses: entropy decoding, inverse quantisation (multiply back by the table values), and inverse DCT. But the original real-valued coefficients are gone; only rounded integers survive. That irreversible rounding is what makes the process lossy and what gives investigators a record of the compression quality.

Quantisation tables as camera and software fingerprints

The JPEG standard specifies the DCT and the entropy coding but not the quantisation tables. Manufacturers are free to use their own tables, and they do. Canon's firmware uses different table values from Nikon's; Photoshop's default tables differ from those produced by smartphone ISPs from Apple, Samsung, or Google. The tables are stored in the JPEG file header and can be extracted in seconds with any EXIF reader.

The forensic implication runs in two directions. First, the table narrows the field of possible creation tools. A file claiming to come from a specific camera model should carry that model's characteristic tables. A mismatch between the claimed source and the embedded table is an immediate red flag. Second, if a region of the image was pasted in from a source that used different tables, the pasted region's coefficient distribution will carry the fingerprint of the source table, not the host table. Segmenting the image and comparing per-region table estimates is a form of localisation.

Double-JPEG compression: the statistical signature

In a singly-compressed JPEG, the DCT coefficient histograms for any given frequency tend to follow a smooth, roughly Laplacian distribution peaking at zero. When the image is decoded and re-saved at a different quality setting, the second quantisation step divides already-rounded values again. The interaction between two different quantisation steps produces a periodic pattern of peaks and valleys in the coefficient histograms. This structure is absent in genuine single-save images and is the signature Farid (2009) used to build his detector.

Single JPEG: smooth LaplacianhistogramDouble JPEG: periodic peaks inhistogramno manipulation signalmanipulation signal present
Single-JPEG vs double-JPEG DCT coefficient histogram shape.

Bianchi and Piva (2012) extended this approach with a statistical framework for estimating the first (primary) quality factor even when the final (secondary) quality factor is known. This is useful because an attacker who saves a manipulated image at a higher quality than the original may hope to wash out evidence of double compression. The Bianchi-Piva estimator can still recover the ghost of the primary quantisation in many cases.

A complication arises when the primary and secondary quality settings are the same. If an image is decoded and re-saved at the identical quality factor, the periodic histogram structure is largely suppressed because the second quantisation steps are aligned with the first. Same-quality double compression is the hardest case for histogram-based detectors, and practitioners should be aware that a clean histogram does not rule it out.

ScenarioHistogram shapePrimary quality recoverable?
Single JPEG at quality QSmooth LaplacianN/A
Double JPEG: Q1 then Q2, Q1 < Q2Periodic peaks at Q1 step intervalsUsually yes (Bianchi-Piva)
Double JPEG: Q1 then Q2, Q1 > Q2Periodic structure may be suppressed by coarser Q2Partially
Double JPEG: Q1 = Q2Largely smooth; signal suppressedDifficult to detect

The JPEG ghost method for region localisation

The double-compression histogram methods work at the whole-image level. For localising which region of an image was tampered with, the JPEG ghost method (Farid 2009) is more directly useful. The logic is straightforward. Take the image, save it at quality Q, then compute the per-pixel absolute difference between the re-saved version and the original. Do this for many quality values, say Q = 50, 55, 60, ... , 95.

A region that was originally captured at quality Q_src will have minimum re-compression error when the re-save quality is close to Q_src. If the whole image was captured at quality 85, the minimum-error map will be near-uniform across the image at Q = 85. But if a region was pasted in from a source captured at quality 70, that region's minimum error will land near Q = 70, producing a visible patch at a different quality level in the error map. That patch is the ghost.

Limitations are real. JPEG ghost relies on the pasted region having come from a source with a meaningfully different quality setting. If the source quality was close to the host quality, the ghost is weak and may not be distinguishable from compression noise. Progressive JPEG encoding, subsampling differences, and some modern adaptive-quality schemes can also affect the result. As with all single-method results, JPEG ghost findings should be corroborated by at least one other method before being presented as the primary evidence of manipulation.

Blockiness inconsistency at splice boundaries

Every JPEG image has a fixed 8x8 block grid anchored to the image's top-left corner. When content is pasted from another image, the pasted region brings its own block grid with it. Unless the attacker is careful to crop and paste at 8-pixel-aligned boundaries, the pasted region's block edges will be offset from the host image's grid. When the composite is saved as JPEG, the encoder tiles the whole image with a new 8x8 grid, and the previously-aligned blocks in the pasted region are now split across new block boundaries. The result is a local increase in blockiness at a phase that differs from the surrounding image.

Grid-alignment analysis exploits this. By computing a blockiness measure at different spatial phases across the image (i.e., at different offsets of the 8x8 tiling), investigators can identify regions where the dominant phase shifts. A step-change in dominant block phase at a sharp boundary is consistent with content from a different source. This method works even when the pasted region and the host share similar quality settings that defeat JPEG ghost analysis.

Check your understanding
Question 1 of 4· 0 answered

What is the forensic significance of the quantisation table embedded in a JPEG file?

Key Takeaways

  • JPEG divides images into 8x8 pixel blocks, applies a DCT, and quantises coefficients; the quantisation table is both the source of quality loss and a fingerprint of the creating device or software.
  • Double JPEG compression produces a periodic structure in DCT coefficient histograms that is absent in singly-compressed images; this is detectable via the Farid 2009 and Bianchi-Piva 2012 methods, though same-quality re-saving suppresses the signal.
  • The JPEG ghost method localises manipulated regions by mapping per-pixel re-compression error across a range of quality levels; a patch with a different minimum-error quality reveals content with a different compression history.
  • Splice boundaries create block-phase shifts when the pasted region's 8x8 grid is not pixel-aligned with the host image; grid-alignment analysis detects these phase discontinuities even when quality settings are similar.
  • No single JPEG method is conclusive; ghost analysis, histogram analysis, and phase analysis are most reliable when they converge on the same region.
What is a DCT block in a JPEG image?
JPEG compression divides the image into 8x8 pixel blocks and applies a discrete cosine transform to each block, converting spatial information into frequency coefficients. These coefficients are then quantised according to a quality-dependent quantisation table. The 8x8 block grid is the fundamental structural unit that both causes JPEG artefacts and enables forensic analysis.
How do quantisation tables act as a camera or software fingerprint?
Different camera manufacturers and software packages use proprietary quantisation tables, which control how aggressively each frequency coefficient is rounded. The specific table values embedded in a JPEG file identify the software or firmware that created it, and inconsistencies between the claimed source and the detected table can indicate post-processing.
What is double-JPEG compression and why does it matter forensically?
Double-JPEG compression occurs when a JPEG image is decoded, edited, and then saved as JPEG again. The second quantisation step acts on already-quantised coefficients and leaves a characteristic statistical signature in the DCT coefficient histograms, specifically periodic peaks or dips that are absent in singly-compressed images. This signature can reveal that an image was re-saved after editing.
What is the JPEG ghost method?
JPEG ghosting involves re-saving the image at multiple quality levels and computing the per-pixel absolute difference between each re-saved version and the original. A region that was pasted in from a different source at a different JPEG quality will show a characteristic minimum-error quality that differs from the rest of the image, revealing its origin as a ghost pattern.
What are blocking artefacts in JPEG images?
Blocking artefacts are visible rectangular patterns that appear at low JPEG quality settings, caused by the discontinuity between adjacent 8x8 blocks quantised independently. At splice boundaries, the block grid of the pasted region may be misaligned with the grid of the host image, creating a detectable phase shift that locates the edit.

Test yourself on Forensic Audio, Video and Image Analysis with free, timed mocks.

Practice Forensic Audio, Video and Image Analysis questions

Found this useful? Pass it along.

Share

Spotted an error in this page? Report a correction or read our editorial standards.

Your journey to becoming a forensic professional starts here.

Practice with mock tests, learn from structured notes, and get your questions answered by a global forensic community, all in one place.