Double JPEG Compression Detection is a forensic method that analyzes an image's Discrete Cosine Transform (DCT) coefficient histograms to identify traces of two distinct compression cycles. When a JPEG is opened, edited, and re-saved, the second compression applies a new quantization table over the first, creating periodic peaks, zeros, or perturbations in the coefficient distribution that are statistically absent in singly compressed images.
Glossary
Double JPEG Compression Detection

What is Double JPEG Compression Detection?
A blind image forensics technique that identifies the statistical fingerprints left when a JPEG image is decompressed, manipulated, and saved again, revealing the presence of a primary and secondary quantization table.
The technique is foundational to image forgery localization because a manipulated region often exhibits a different compression history than the authentic background. By detecting misaligned 8x8 blocking artifacts or inconsistencies in the first-digit distribution of DCT coefficients, forensic analysts can identify spliced or inserted content without relying on embedded metadata or watermarks.
Key Forensic Characteristics
The core forensic indicators that reveal a JPEG image has been decompressed, manipulated, and re-saved. These statistical fingerprints expose the presence of a primary and secondary quantization table, betraying the edit history.
Double Quantization (DQ) Effect
The foundational statistical artifact exploited for detection. When an image is JPEG compressed, its Discrete Cosine Transform (DCT) coefficients are quantized using a specific quantization table. Decompression and re-compression with a different table causes the coefficient histogram to exhibit periodic peaks and valleys—a pattern absent in singly compressed images. The DQ effect is mathematically modeled as the convolution of the original coefficient distribution with a periodic impulse train, creating a detectable comb-like signature in the histogram's Fourier transform.
Ghost Quantization Table Estimation
A forensic technique to estimate the primary quantization table (the table used during the first compression) from the doubly compressed image. By analyzing the periodicity of the DCT coefficient histogram, the step size of the original quantizer can be recovered. This is achieved by computing the Power Spectral Density (PSD) of the histogram; the location of the dominant peak in the PSD directly corresponds to the primary quantization step. This reveals the compression history even when the final image quality is high.
JPEG Ghost Detection
A visualization method that re-compresses the suspect image at various quality factors and subtracts the result from the original. When the re-compression quality factor matches the primary compression quality, the difference image reveals a faint 'ghost' of the original compression structure. This occurs because the DCT grid aligns perfectly with the original block boundaries, minimizing the difference. Misaligned grids produce a strong, visible grid artifact. This technique is effective for detecting localized tampering where a spliced region has a different compression history.
Blocking Artifact Inconsistency
JPEG compression introduces blocking artifacts at 8x8 pixel boundaries due to independent quantization of each DCT block. In a doubly compressed image, these block boundaries may be misaligned if the image was cropped between compressions. By measuring the Blocking Artifact Strength (BAS) across the image grid, forensic analysts can detect regions where the 8x8 grid structure is inconsistent. A shift in the grid alignment creates a detectable periodic pattern in the difference image, localizing the tampered region.
First Digit Benford's Law Violation
The distribution of the first digits of quantized DCT coefficients in a singly compressed JPEG follows a generalized Benford's Law distribution. Double compression disrupts this logarithmic distribution, causing statistically significant deviations. By applying a chi-squared goodness-of-fit test against the expected Benford distribution, forensic tools can flag images with a high probability of re-compression. This method is computationally efficient and works as a blind detection technique without requiring knowledge of the original quantization table.
JPEG Dimples Artifact
A specific visual artifact introduced by the rounding and truncation of DCT coefficients during double compression. When a coefficient is quantized, de-quantized, and re-quantized, the rounding error creates a characteristic dimple pattern in the coefficient histogram at integer multiples of the quantization step. These dimples are a direct consequence of the double rounding operation and are highly specific to the JPEG pipeline. Their presence is a strong indicator of re-compression, even when the two quality factors are similar.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about detecting re-compression artifacts in digital images.
Double JPEG compression occurs when an image is decompressed from its original JPEG state, undergoes some form of manipulation (such as splicing or object removal), and is then saved again as a JPEG. This process leaves behind a distinct statistical fingerprint: the presence of two separate quantization tables—the primary table from the first save and the secondary table from the second. In forensic analysis, this is a major red flag because an authentic, untouched camera original should only ever exhibit a single compression history. The detection of a double compression event strongly suggests that the image was opened in editing software and re-saved, providing a critical lead for establishing evidence of tampering even when the visual manipulation is imperceptible to the naked eye.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Double JPEG compression detection is one node in a broader forensic toolkit. These related techniques analyze different statistical fingerprints to build a complete picture of an image's manipulation history.
Error Level Analysis (ELA)
A forensic method that re-saves an image at a known quality level and computes the difference from the original. Regions with different compression histories—such as spliced-in objects—will exhibit distinct error levels, visually highlighting potential manipulation zones.
- Identifies inconsistent compression ratios across an image
- Effective for detecting splicing and airbrushing
- Outputs a heatmap where brighter areas indicate higher potential tampering
Quantization Table Analysis
The core mechanism behind double JPEG detection. Every JPEG encoder uses a quantization table—a 64-entry matrix that determines how aggressively each DCT frequency coefficient is compressed. When an image is decompressed and re-saved, the secondary quantization table leaves a distinct statistical signature that can be estimated from pixel values alone.
- Reveals the primary compression quality even after re-saving
- Mismatched tables across image regions indicate localized tampering
- Tables are often unique to specific camera models or software
JPEG Ghost Detection
A technique that searches for residual evidence of a previous compression grid that is no longer aligned with the current 8×8 block structure. By computationally shifting the decompression grid and re-compressing, analysts can detect 'ghost' boundaries where the original blocking artifacts persist.
- Detects cropping and rotation after initial compression
- Exploits blocking artifact misalignment
- Reveals whether an image was resized between saves
Benford's Law Analysis
A statistical forensic method that tests whether the distribution of first digits in DCT coefficients follows the expected logarithmic distribution. Natural, single-compressed images conform closely to Benford's Law; double-compressed or manipulated images exhibit measurable deviations.
- Detects anomalous coefficient distributions
- Effective against seam carving and inpainting
- Used as a blind forensics technique requiring no reference image
Blocking Artifact Grid Analysis
Examines the periodic 8×8 blocking grid inherent to JPEG compression. When an image is cropped or spliced, the grid alignment shifts, creating detectable discontinuities at manipulation boundaries. This technique measures the periodicity and strength of blocking artifacts across the image.
- Detects grid misalignment from cropping
- Identifies pasted regions with different artifact patterns
- Complements quantization table analysis for tampering localization

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us