I have a couple of JPEGs. Is there a way to find out which compression level was used when encoding them? That is, were they encoded at level 60 or 90?

The reason I'm asking is because I have a site where I use compressed images, which was compressed in a particular program. Now I want to compress the reset of my images in the same program and at the same level so they will kind of look "as bad" as the other ones :)

  • what is the practical reason for the question? What do you want to achieve in the end? i am asking because maybe there is another solution Mar 25, 2017 at 3:07
  • @aaaaaa I added some more info to my question regarding the reason I'm wondering. Maybe you have a good suggestion for that scenario? Mar 25, 2017 at 20:37

2 Answers 2


No, you can not and it does not make sense to do so, since there is no ubiquitous definition of the JPEG compression level. The actual result when saving a JPEG with compression level 60 in one software can differ significantly from what another software produces when set to level 60.

If you use ImageMagick as suggested by Rolazaro Azeveires, it will indeed print a quality-number, but this number is not based on EXIF data. ImageMagick calculates its own quality-index based on the number of quantization tables in the image file and this number may again differ from the quality level you actually set when saving the image.

For example, if you have a structurally simple image, the simplest being a single-coloured tile, and you save it at level 100 with a software using a perceived quality index, the software can save the image essentially lossless with only a small number of quantization tables. Analyzing the file later with ImageMagick is likely to give you a very low quality level, since ImageMagick only sees a few quantization tables and does not realize that actually only a small number of quantization tables was necessary to save the file at a high quality setting.

Here are for example the quality reported by ImageMagick for some different options when saving an image from Photoshop:

Photoshop                 ImageMagick identify -verbose
save for web q=1/100         Quality: 55
save for web q=80/100        Quality: 94
save for web q=100/100       Quality: 99
save image q=1/12            Quality: 81
save image q=6/12            Quality: 92
save image q=12/12           Quality: 99

As you can see, even within one software, two different functions 'save image' and 'save for web and devices' are both using different quality level scales and neither match the quality level reported by ImageMagick.

Addition: Since Chris H tries to argue that the quality level as reported by ImageMagick can be useful in some cases, I will show some examples why that is not the case. The only reasonable way to judge the quality of a JPEG file is to look at it and not to rely on some magic number procuded by a software tool.

Let's first look at this JPEG file. Yes, the quality is not exceptionally good, there are some visible artifacts and ImageMagick reports a quality of 62 while the file size is 17.426 bytes:

enter image description here

Let us assume that we have the same image from a different source and for this file, ImageMagick reports a quality of 99 and the file size is 21.470 bytes:

enter image description here

It should IMHO be very obvious that neither file size nor ImageMagick's quality level are suitable to judge the true quality of an image file.

  • 1
    You mean kilobytes, not bytes. Also, if you saved the image with a very low quality, then re-saved those artefacts with very high quality, then that's not a very relevant test for most use cases?
    – Chris
    Apr 22, 2020 at 11:19
  • @Chris I have no idea what you mean. I mean 'bytes' everywhere, where I have written 'bytes' in my answer.
    – jarnbjo
    Apr 22, 2020 at 14:29
  • Ahh, apologies, you're using . as a thousand separator rather than a decimal place. My point on relevance is that your Photoshop quality is indicated by the ImageMagick quality, so could be useful, unless you're trying to catch someone who has deliberately saved lossy then re-saved less lossy. Assuming this isn't the case for the OP, they could experiment to find settings to get a similar quality level from ImageMagick.
    – Chris
    Apr 22, 2020 at 14:52
  • @Chris There is no need to deliberately do anything stupid to run into the problem I am describing. Yes, I have resaved the image with a better quality than in a previous save operation, but that was just to show the effect. That is not the only way to run into the problem. The point was just to show that there is no relation between the number of quanitzation tables in or the file size of a JPEG file and the perceived image quality.
    – jarnbjo
    Apr 22, 2020 at 15:47
  • For more confirmation that the quality numbers are not comparable across softwares see faqs.org/faqs/jpeg-faq/part1/section-5.html from the jpeg creators themselves. Feb 18, 2021 at 23:14

You can, sort of. ImageMagicks' identify command can show a estiamte

identify -verbose image.jpeg

will produce (a lot of) information about the image.

One of the lines will be something like:

Quality: 84

If that command shows too much, and you only need the quality, you may pipe it with grep:

identify -verbose image.jpeg | grep Quality

(Stolen and expanded from "How to find the jpg quality", at superuser.com)

(edited, to include that it is not EXIF data but a guesstimate, and to say "go and read the other nice, and probably better, answer" :-)

  • 1
    This does assume the metadata has not been stripped, such as is the case with many images displayed on the web.
    – Michael C
    Mar 24, 2017 at 8:36
  • 2
    @MichaelClark You are right, but the answer is not correct. ImageMagicks does not use the EXIF data to produce the quality level, but counts the number of quantization tables. See my answer for a longer explanation why not even that is a particularly clever approach.
    – jarnbjo
    Mar 24, 2017 at 11:37
  • This is still helpful in some cases, though - if used carefully. File size might be simpler but if images have also been batch processed for resolution you might need to take both into account.
    – Chris H
    Mar 25, 2017 at 8:24
  • @ChrisH Depends on what you are looking for. Both file size and the 'quality' index determined by ImageMagick are purely technical values with no reliable dependency on the perceived quality of the image.
    – jarnbjo
    Mar 25, 2017 at 11:02
  • 1
    @RolazaroAzeveires No, there is a correclation between the ImageMagick quality index and the technical quality loss imposed during the last JPEG compression step of the image. There is no correlation between the IM quality index and the perceived quality.
    – jarnbjo
    Mar 28, 2017 at 10:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.