When I save a JPG file with GIMP, I can adjust the quality I save it at, from 0-100 (I use 89). It seems like I've used an app to see what this number was on saved file but if I did I can't for the life of me figure out what it was. Any suggestions as to what to use?
8 Answers
To add to Arjan's answer:
ImageMagick's identify appears to actually look inside the JPEG image to guess the quality setting used to encode it.
ImageMagick's source code (cheer for free software :-)) contains the lines:
/*
Determine the JPEG compression quality from the quantization tables.
*/
sum=0;
for (i=0; i < NUM_QUANT_TBLS; i++)
{
if (jpeg_info.quant_tbl_ptrs[i] != NULL)
for (j=0; j < DCTSIZE2; j++)
sum+=jpeg_info.quant_tbl_ptrs[i]->quantval[j];
(coders/jpeg.c, line 843ff. in my recent version of ImageMagick's source code).
I don't know enough about JPEG to really understand, but it appears to do something like described in this article:
Determine the JPEG quality factor by using Visual C# .NET (link dead as of Januar 2018; copy on archive.org from 2015)
So yes, identify can actually determine the quality setting of a JPEG just from the compressed file alone (though the result may not always be completely accurate).
- 23,525
Once saved, you cannot tell the quality anymore.
(Setting the quality while saving just tells the software how much loss you find acceptable, but once saved: what's lost is lost. You'd need a human to say if something looks nice.)
Hmmm, I guess I was wrong. I still think the above is correct, but ImageMagick's identify proves me wrong?
identify -verbose myimage.jpg Image: myimage.jpg Format: JPEG (Joint Photographic Experts Group JFIF format) Class: DirectClass Geometry: 358x240+0+0 Resolution: 300x300 [...] Compression: JPEG Quality: 90 Orientation: Undefined [...]
I don't know how the image in my test was saved, but it does not have any EXIF data. Could the quality still be stored in the image?
- 31,511
As Arjan metioned identify -verbose myimage.jpg will do it. As imagemagick is a CLI tool, it may be useful for scripting. The approach identify -verbose myimage.jpg | grep ... is preety slow. I recommend using IM like this
identify -format '%Q' myimage.jpg
It is massively faster.
- 1,282
Picasa 3 has the properties pane which shows the jpeg quality but it is an abandonware at the moment.

- 1,444
A note on the answers above that suggest ImageMagick: ImageMagick's current (November 2024 as I'm writing this) algorithm for estimating JPEG quality is pretty unreliable. Its overall objective is to find a match with the quantization tables that follow from a set of "standard" tables in the JPEG standard. By itself this approach makes perfect sense, but it does this by matching aggregated values of the quantization coefficients (sums and hashes). This make the algorithm vulnerable to collisions. It also does something weird at low (<50%) qualities. See for details this blog post I wrote about this:
In the end I wrote my own Python implementation of an algorithm that uses simple least-squares matching to find the closest "standard" quantization tables. It then reports the corresponding quality level, as well as a statistical measure that expresses how well the closest "standard" tables actually match the image's quantization tables (which is useful for assessing the accuracy of the estimate).
See below post for a detailed explanation, with links to code and test data:
This also includes a comparison of this method against the ImageMagick method, which shows they can yield very different quality estimates.
Note that ExifTool (mentioned by Mark Setchell) uses the same quality estimation algorithm as ImageMagick, so it has the same limitations!
I have already reported this on Github to the ImageMagick and ExifTool developers, so hopefully they change it at some time in the future.
- 211
With ImageMagick++ library it's easy:
Image magick_image( pathname );
size_t compressionFactor = magick_image.quality(); // 0..100
- 111
You can use exiftool to guesstimate the JPEG quality like this:
exiftool -JPEGQualityEstimate *.jpg
Let's make some images with varying quality using ImageMagick and see what exiftool makes of them:
# Make some JPEGs of known quality
magick -size 640x480 xc: +noise random -quality 35 35.jpg
magick -size 640x480 xc: +noise random -quality 70 70.jpg
magick -size 640x480 xc: +noise random -quality 78 78.jpg
magick -size 640x480 xc: +noise random -quality 92 92.jpg
Check them out with exiftool
exiftool -JPEGQualityEstimate ??.jpg
======== 35.jpg
JPEG Quality Estimate : 35
======== 70.jpg
JPEG Quality Estimate : 70
======== 78.jpg
JPEG Quality Estimate : 78
======== 92.jpg
JPEG Quality Estimate : 92
Looks pretty accurate.
- 762