# What is error level analysis (ELA), and does it work on AI images?

Source: https://passreal.com/guides/error-level-analysis

Error level analysis saves a JPEG again at a known quality and displays the difference from the original. Regions that were compressed differently, such as pasted or edited areas, can stand out. It is a hint for spotting splices, not a test for AI generation, and its output is easy to over-read, because texture, edges and resizing also change the error level.

## The idea behind ELA

JPEG is lossy. Each time an image is saved, the encoder divides blocks of the
picture into frequency components and rounds them. The first save introduces
rounding errors. A second save at the same quality introduces fewer, because the
values are already close to what the quantiser would produce. A region that has
been through fewer or different saves behaves differently from the rest.

Error level analysis exploits that. You save the image again at a chosen quality,
take the pixel-by-pixel difference from the original and amplify it so the
differences are visible. In an image saved once, the error should be fairly even for
similar content. In a composite where one region came from another file, the region
with a different history can show a distinct error level.

## How to read an ELA picture

- A dark area means the region changed little when recompressed.
- A bright area means it changed a lot.
- Sharp edges and high-contrast textures are bright in almost any photograph,
  because high-frequency detail is what quantisation changes most.
- Smooth gradients and flat colour are dark.

The risk is reading brightness as evidence of editing when it is only evidence of
detail. The useful signal is inconsistency: two regions with similar texture but
very different error levels.

## Why it does not detect AI generation

An image made by a generator and saved once as a JPEG has a single compression
history. There is no pasted region and no earlier save to contrast with. [ELA](/detectors/fotoforensics-ela) has
nothing to compare, and the result looks like any single-save photograph.

Resizing makes the picture even less informative. Scaling resamples every pixel and
discards the block structure ELA relies on. Social platforms resize and recompress
uploads, which is why ELA on a downloaded copy often shows a uniform wash.

Some detectors do use compression cues, but they are trained classifiers using many
features, not a simple difference image.

## What forensic analysts add

Careful analysts combine ELA with other evidence.

- **Metadata.** EXIF, XMP, IPTC and C2PA state origin and edit history.
- **Quantization tables.** The tables in a JPEG identify the encoder. A mismatch
  with the declared camera is a clue.
- **Sensor noise.** Real cameras leave a pattern that varies by device, and
  generated images do not carry one.
- **Frequency analysis.** A Fourier transform can reveal periodic patterns from
  upsampling layers.

## How it interacts with processing

When PassReal processes an image, the output is a freshly encoded JPEG. That gives
it one compression history from the pipeline's final save, with quantization
tables matched to the declared camera and EXIF from a real camera body. Before that
step, the pipeline removes C2PA, IPTC digital source type, XMP and PNG text chunks,
adds a sensor model and filters the spectrum.

That is a description of what the file contains, not a promise about forensic
tools. ELA is interpretive, and different analysts read the same picture differently.
PassReal does not remove SynthID or any pixel-level watermark.

## Using ELA responsibly

- Always compare against a known original of similar content if you can.
- Try several quality settings and see whether the pattern persists.
- Never treat one ELA image as proof. Corroborate with metadata or another method.
- Avoid accusing anyone based on a bright region.

## A worked example

Take a phone photo, save it as a JPEG, and run ELA. You will see bright outlines around edges and darker flat areas. Now paste a small logo from a different file onto it, save once, and run ELA again. The logo region often shows a distinct brightness from the surroundings, because it carries a different compression history. Finally, resize the whole image by a third and repeat. Most of the contrast between the pasted region and its surroundings fades. That sequence shows both the usefulness and the fragility of the method.

## Try it on your own file

Run ELA on one of your images, process the same file with PassReal's three free
images, and run ELA again. Comparing the two tells you more about the method than
any explanation does.

## Questions

### Can ELA tell me whether an image is AI-generated?

Not reliably. It was designed to flag regions with a different compression history, which suits spliced photos. A fully generated image has one history, so there is nothing to compare.

### How do I run ELA?

Save the image as a JPEG at a fixed quality, subtract it from the original, amplify the difference and view it. Many free web tools and forensic suites do these steps for you.

### Why do edges and textures look bright in ELA?

High-frequency detail changes more when compressed again, so sharp edges and fine textures show larger differences even in an untouched photograph.

### Does PassReal affect ELA?

Yes, because it re-encodes the image as a JPEG, which gives the file a fresh compression history. We make no claim about how any forensic reading will interpret it.

### What is a better check for provenance?

Read the metadata and any C2PA manifest first, since they state origin directly. Treat ELA as one clue among several, not a verdict.

Try it: https://passreal.com/app (three images free)
