Jump to content

A tool to determine the quality setting of a JPEG file


Recommended Posts

Hello Everyone,

 

As a standard disclaimer I have checked the archives and didn't really

find anything like this, I could have missed it, if so I apologize in

advance.

 

I am in the process of trying to determine what quality setting was

used to compress a JPEG file. I have found one tool 'jpegdump' that

seems to get close but it seems that the quality factors for photoshop

compressed jpegs below quality level 7, the quality factors seem to

increase. For example, I have the same file that I compress with PS 7

with quality level '7' and the quality factors are '77' and '87' for

each table. An image compressed at '6', the factors are '81' and '91'.

It could be that I don't understand the 'scale' and 'var' numbers

correctly (any help with these would be great). Are there an other

tools for determining this? Does anyone know of a resource that I

could you to write a program to determine this? I have checked

'jasper' library, 'libjpeg' and 'jpegdump' of which 'jpegdump' seems

to be the only one that has support for this.

 

Thanks in advance,

 

Lee

Link to comment
Share on other sites

I will hazard a guess without looking into it personally since no one else

has responded. i.e., this is your baby and you can always read it <a

href=http://www.wotsit.org/download.asp?f=itu-1150PDF>in the standard</a>

and research beyond that if need be. But that is work and no one is likely

to finish such in a day. Let alone a few minutes.<p>

 

The first thing to think about is words used. PS lets us save a JPEG with

<b>quality</b> values ranging from 1 to 12. PS & IR (ImageReady)let us save

a JPEG with a <b>quality</b> value ranging from 1 to 100. Now what quality

means is that the higher the <b>quality</b> the less <b>compression</b> that

is applied during JPEG creation. Hence we get the following

<i>qualitative</i> relationship:<p>

 

<b>quality</b> = 12- <b>compression</b> (<b>Save As</b>)<p>

<b>quality</b> = 100- <b>compression</b> (<b>Save For Web</b>)<p>

 

What this tells us is that as quality increases compression must

comensurately decrease. Hence if we rearrange the above expressions we

get.<p>

 

<b>compression</b> = 12- <b>quality</b> (<b>Save As</b>)<p>

<b>compression</b> = 100- <b>quality</b> (<b>Save For Web</b>)<p>

 

Now this is just a <i>qualitative</i> relationship and this means we could

use it to begin exploring an analysis of the subject, but it is not

something we can code software with. As you have already seen, the range of

values that <b>Save As</b> uses maps to two different values in the actual

image files. Similarly <b>Save For Web</b> will map its range of 1-100 to

two different values in the image file. Another program, Paint Shop Pro,

actually uses a <b>compression</b> setting rather than a quality setting

from what I have heard (I have never used it myself). <p>

 

Anyway, this should roughly answer your question and anything deeper will

require you to read <a

href=http://www.wotsit.org/download.asp?f=itu-1150PDF>the standard</a> or

one of the posters with deeper experience with the standard to post. <p>

 

In short, as quality goes down, the amount of compression goes up. This is

apparently specified by two values in the actual jpeg file itself (IIRC, the

quantization tables are implementation defined so it is more complex in

reality).<p>

 

hope this helps, <p>

 

Sean

Link to comment
Share on other sites

Which version of Photoshop are you using? The newer versions have

excellent quality (better than IJG libraries) at the low Q levels,

so maybe the difference in 6-7 size is due to chroma subsampling.

Older versions (5.5 and ??) were linear according to our tests.

Hopefully Gordon will see this thread soon.

Link to comment
Share on other sites

Beyond a certain threshold, PS doesn't use chroma sub-sampling (unlike the IJG code which always does), and this may be what fools your app.

 

Also, it's possible that PS may use more than a dumb decimation when compressing JPEG, e.g. in order to avoid added contrast along the 8x8 lines.

 

Finally, you can't really measure the quality, since that would essentially be a problem of measuring data that isn't there. A plain-colored image (with the right color choice so that the RGB<->YUV conversion is exact enough) will compress losslessly with only DC components, at any "quality setting".

Link to comment
Share on other sites

I wrote a very lengthy article for photo.net on <a href="http://www.photo.net/learn/jpeg/">Jpeg Compression</a> (http://www.photo.net/learn/jpeg/), which covers JpegDump and many other topics.

<p>

I suggest you read it (this may take several hours to understand properly). After that you might be able to answer your own question better than anybody on the forum (since we don't have access to all the information, copies of Jpeg's etc).

Link to comment
Share on other sites

Thanks for the Input so far.

 

Jean-Baptiste Queru wrote -

'Finally, you can't really measure the quality, since that would essentially be a problem of measuring data that isn't there. A plain-colored image (with the right color choice so that the RGB<->YUV conversion is exact enough) will compress losslessly with only DC components, at any "quality setting".'

 

I can understand this but what the Jpegdump and my code with 'libjpeg' does is measure the differences between the standard luminance and standard chrominance quatification tables (these are in the spec) and the quantization table stored in the image. Using the difference the compression quality is guessed at.

 

I'm think they Chroma sub-sampling differences would affect the way this table is built and cause differences, is there a way to access the chrome sub-samping in the compressed image? And in the article 'JPEG Compression' there are chroma numbers pulled out of 'jpegdump' but I'm not sure how. (http://www.photo.net/learn/jpeg/#chrom) I must be missing something, its been a long day.

 

Thanks.

Link to comment
Share on other sites

To summarise a very complex topic:

 

1. Photoshop tables are very different from the standard (IJG) tables, and jpegdump will never be able to give an exact match for a Jpeg compressed with Photoshop, since jpegdump can only estimate IJG tables.

 

2. It is well known that older versions of Photoshop vary the chroma subsampling as the quality setting is reduced - this is done at some arbitrary point in the scale (e.g. 7 to 6), and the user does not have the ability to control this chroma setting.

 

3. What are you trying to achieve with this process? Is it to improve your online images, or are you just trying to understand this for recreation?

 

4. If you really want to know more, contact me directly. I don't think photo.net members would benefit greatly from this particular discussion.

Link to comment
Share on other sites

Thanks for your summary.

 

To answer point 3. In the future content producers (i.e. magazines) are looking at gatekeeping in coming images based upon jpeg compression levels (in one standard (disc-info.org)) they are using Photoshop quality levels as the benchmark. If I am unable to find a tool to give a estimated figure for this, I will write one. As I learn about JPEG I finding it (not suprisingly since it is a lossly compression format) that it is difficult. As to point 4, you are probably correct in the detail we are discussing but in the future if any 'photo.net' members are selling/submitting images to these publishers then this thread might be helpful to understand. I will contact you offline.

 

Once again thanks for your help.

Link to comment
Share on other sites

Photo.net has a user-upload gallery (as do other photo forums), and has gone through a lengthy period of debate about what size images should be allowed. Recent changes have satisfied most people, but no rule can work for every image, since Jpeg file sizes vary enormously with image content (detail) and dimensions.

 

I think I understand the broad aim, but I think it clashes with the reality that Jpeg is a complex subject, and not very amenable to 'top-down' rules. Photoshop is not the only image editor on the market, and it is arguable whether it provides the best tradeoff between size and quality. (For the record - I am not a Photoshop user).

 

This subject is a real hot-potato IMO...

Link to comment
Share on other sites

Personally I feel that GIMP is a better tool than Photoshop for

editing JPEG, because it provides control over chroma subsampling

and uses IJG libraries, which provide better size/quality tradeoffs

at high Q levels (assuming JPEG is for the web). Lee, I hope you

got your questions answered. One Gordon missed: you can tell 1:1

chroma subsampling when <B>jpegdump</B> reports "id 1" as 1 for both

vertical and horizontal (otherwise both are 2).

Link to comment
Share on other sites

Looking at the website <a href="http://www.disc-info.org/">Digital Image Submission Criteria</a> (disc-info.org) indicates that the question is much more complex than just determining the compression level of a given Jpeg. This site is worth reading for those interested in digital image upload submissions.

<p>

Using a specific level of compression as a criterion is not helpful IMO - using bits-per-pixel is better over a wider range of images.

The acceptable level of compression varies tremendously from 0.5 bits/pixel to 4 bits/pixel, which is a huge range in file-sizes.

<p>

Bill: Chroma subsampling is mentioned in my article (I forgot to repeat it in my response above). I did contact the poster privately, but the subject is a rather complex one.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...