• Understanding Quality
  • Quantization Tables
  • Details
  • Mapping Values
  • Estimating Quality

Tutorial: Estimate JPEG Quality

JPEG images use a variable quality level to control the amount of compression. However, the JPEG quality is typically not stored in the metadata. There are ways to estimate the JPEG quality level last used to save the image.

Understanding Quality

JPEG images use a lossy compression algorithm. This algorithm trades quality for compression. A low-quality image results in a smaller JPEG file; a high-quality image generates a relatively large file. This is different from lossless image formats, such as PNG, BMP, and PPM, where the quality never degrades.

The amount of JPEG compression is typically measured as a percentage of the quality level. An image at 100% quality has (almost) no loss, and 1% quality is a very low quality image. In general, quality levels of 90% or higher are considered "high quality", 80%-90% is "medium quality", and 70%-80% is low quality. Anything below 70% is typically a very low quality image.

For example, the following pictures were saved at different quality levels. The first picture is a PNG (not a JPEG) and represents the baseline lossless (100% quality) image. The next four images show the baseline picture saved at 90%, 80%, 70%, and 25% quality.

ImageDifference from baselineDescription
Baseline lossless (100% quality) image. (Source: "Glasses, pitcher, ashtray and dice (POV-Ray)", Gilles Tran, 2006).
Baseline image saved as a 90% quality JPEG.

Visibly, there is very little difference. Only the edges are a little less crisp.
Baseline image saved as a 80% quality JPEG.

Fine details, like the dice and glass bases, are a little blurry.
Baseline image saved as a 70% quality JPEG.

Edges are no longer crisp and compression artifacts are visible. E.g., the base of the pitcher's curved handle (behind the nearly empty glass) is very blurry and distorted.
Baseline image saved as a 25% quality JPEG.

Significant JPEG artifacts are visible around all edges. Most appear as ripples and echo lines.

Quality Impact

The selected quality level is used to determine the quantization tables used with the JPEG image. The quantization tables control the amount of loss during the compression and the size of the compressed file. This means that the quality level directly impacts the visual quality of the image and the file size.

From a forensic viewpoint, there is another impact from quality. Low quality images can reduce the ability to detect modifications with some analysis algorithms. For example, Error Level Analysis (ELA) works by resaving an image at a known quality level, such as 75%, and then identifies the amount of error introduced during the resave. If the image was last saved at 75%, then ELA at 75% is unlikely to highlight any change. This can be problematic when you consider that picture hosting sites like Facebook may resave JPEG images at 75% quality or lower; with ELA, a picture from Facebook is unlikely to have any identifiable modifications. Similarly, analysis algorithms based on signal noise detection and focal quality are unlikely to be effective on low quality images. In contrast, analysis based on JPEG artifact detection may still be applicable, even on very low quality images.