Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

JPEG "quality" - can it be discovered from the compressed file?

57 views
Skip to first unread message

Aandi Inston

unread,
Jun 29, 1998, 3:00:00 AM6/29/98
to

I'd be glad of a quick possible/impossible judgement on whether the
"quality" settings in a JPEG data stream can be deduced in any
reliable way from the stream itself?

This may be presumed to apply to a single compression process (like
Adobe Photoshop or Acrobat Distiller, say).

I realise that the linear "quality" gets translated to coefficients of
various kinds, but are they stored, making it possible to get back the
original quality settings, or does the decompression work without that
context?

If the info is there to be found, I'll buy the Giant Book of JPEG and
read it.
----------------------------------------
Aandi Inston qu...@dial.pipex.com
Visit http://www.quite.com/ps/ for information on
PostScript, including EPS in 10 easy stages.

Tom Lane

unread,
Jun 30, 1998, 3:00:00 AM6/30/98
to

qu...@dial.pipex.com (Aandi Inston) writes:
> I'd be glad of a quick possible/impossible judgement on whether the
> "quality" settings in a JPEG data stream can be deduced in any
> reliable way from the stream itself?
> This may be presumed to apply to a single compression process (like
> Adobe Photoshop or Acrobat Distiller, say).

It is certainly possible to inspect the quantization tables stored
in a JPEG file. If you know which encoder produced the file then
you can determine what quality setting it was set at. If you
*don't* know which encoder produced the file then the question is
rather meaningless, since different JPEG implementations offer
different quality scales (= mappings from user-specified quality
numbers to quantization tables).

You might be entertained by looking at
ftp://ftp.netcom.com/pub/tg/tgl/jpeg/jpegdump.zip.

regards, tom lane
organizer, Independent JPEG Group

paulw...@my-dejanews.com

unread,
Jun 30, 1998, 3:00:00 AM6/30/98
to

In article <uo9lnqf...@netcom6.netcom.com>,

Tom Lane <t...@netcom.com> wrote:
>
> qu...@dial.pipex.com (Aandi Inston) writes:
> > I'd be glad of a quick possible/impossible judgement on whether the
> > "quality" settings in a JPEG data stream can be deduced in any
> > reliable way from the stream itself?
> > This may be presumed to apply to a single compression process (like
> > Adobe Photoshop or Acrobat Distiller, say).
>
> It is certainly possible to inspect the quantization tables stored
> in a JPEG file. If you know which encoder produced the file then
> you can determine what quality setting it was set at. If you
> *don't* know which encoder produced the file then the question is
> rather meaningless, since different JPEG implementations offer
> different quality scales (= mappings from user-specified quality
> numbers to quantization tables).
But in any case investigating the quantization tables won't tell
the whole story if some of the more novel pre-filtering techniques
have been used. These (effectively) degrade the image in hopefully
useful ways before JPEG gets a look in. You therefore cannot
get the quality measure by just looking the JPEG numbers
You could argue that this is not JPEG. But joe-user is just hitting save-as.

BugBear.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

Jack Berlin

unread,
Jun 30, 1998, 3:00:00 AM6/30/98
to

Hi,
The quality of the compression in a JPEG stream depends on the
quantization values used, which are part of the header information for
the stream (in the DQT marker segment(s)). The quality for a color image
can also depend on the subsampling used for the chrominance components,
which is also discoverable (from the Frame header). So in that sense it
is possible to deduce the quality of the compression from the stream.
But there are a few things to be aware of: (1) A given set of
quantization values does not produce the same VISUAL quality on all
images. And subsampling of chrominance sometimes causes no visually
perceptible loss, and sometimes it does cause noticeable visual loss.
(2) There is not one number that determines the quantization and hence
the quality in JPEG, there are 64 numbers for each color component.
Many people use the values suggested in Annex K of the ISO/IEC DIS
10918-1 document (the JPEG spec), scaled up for lower quality or scaled
down for higher quality. That way a single number (a function of the
scaling factor) can be used to determine a quality setting. But not
every JPEG stream is going to have quantization values that are simply a
scaling of these suggested values, so it is not always going to be
possible to state a single number for the quality setting of an
arbitrary jpeg stream.

On some compressors, when you change quality setting, you may be
changing the subsampling as well as the quantization. (3) It could be
that the compressor does not even follow exactly the quantization values
that are in the DQT marker segment(s), for various reaons (for example,
the quantization interval about 0 may be enlarged sometimes to save
bits). If that was done, there is no way to find out what was the
actual quality of compression from the stream. But this is not commonly
done.

If you actually want to read the JPEG markers to get this information,
it is very simple, but you probably will need to get the "Giant Book"
(Pennebaker-Mitchell), or the ISO spec, to figure out how to do it (or
get someone else who has read the spec to show you how).

Sorry, no simple answers I'm afraid, but hope this helps.
Good luck,
jack
(member, jpeg standards committee)
--
| Check out "BETTER JPEG" live: http://www.jpegwizard.com/ |
| Come see us at the 9th Annual Borland Conference in Denver |
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| Jack Berlin - Pegasus Imaging Corp - BETTER DIGITAL IMAGING! |
| http://www.jpg.com/ - jbe...@jpg.com - 813-875-7575 x303 |
|--------------------------------------------------------------|


Aandi Inston wrote:
>
> I'd be glad of a quick possible/impossible judgement on whether the
> "quality" settings in a JPEG data stream can be deduced in any
> reliable way from the stream itself?
>
> This may be presumed to apply to a single compression process (like
> Adobe Photoshop or Acrobat Distiller, say).
>

Aandi Inston

unread,
Jun 30, 1998, 3:00:00 AM6/30/98
to

Tom Lane <t...@netcom.com> wrote:

>qu...@dial.pipex.com (Aandi Inston) writes:
>> I'd be glad of a quick possible/impossible judgement on whether the
>> "quality" settings in a JPEG data stream can be deduced in any
>> reliable way from the stream itself?
>> This may be presumed to apply to a single compression process (like
>> Adobe Photoshop or Acrobat Distiller, say).
>

>It is certainly possible to inspect the quantization tables stored
>in a JPEG file. If you know which encoder produced the file then
>you can determine what quality setting it was set at. If you
>*don't* know which encoder produced the file then the question is
>rather meaningless, since different JPEG implementations offer
>different quality scales (= mappings from user-specified quality
>numbers to quantization tables).
>

>You might be entertained by looking at
>ftp://ftp.netcom.com/pub/tg/tgl/jpeg/jpegdump.zip.

I was indeed. Thanks to all for the information. For what it's worth,
this is the result, which is specifically designed to identify what
level of JPEG compression was used by Acrobat Distiller, when
examining the contents of a PDF file. Not exhaustively tested but
seems to work.

/* Routine to get the DQT without its type and length */
if ( GetDQTFromStream ( obj , &dqt , &dqtlength ) )
{
strcpy ( buffer , "unknown" ) ;
if ( dqtlength > 64 )
{
unsigned char *d = (unsigned char *)dqt ;
if ( d[1] == 2 && d[64] == 10 )
strcpy ( buffer , "low" ) ;
else if ( d[1] == 4 && d[64] == 20 )
strcpy ( buffer , "med-low" ) ;
else if ( d[1] == 8 && d[64] == 39 )
strcpy ( buffer , "medium" ) ;
else if ( d[1] == 14 && d[64] == 64 )
strcpy ( buffer , "med-high" ) ;
else if ( d[1] == 18 && d[64] == 68 )
strcpy ( buffer , "high" ) ;
}
FreeDQTArea ( dqt ) ;

Tom Lane

unread,
Jul 2, 1998, 3:00:00 AM7/2/98
to

paulw...@my-dejanews.com writes:
> But in any case investigating the quantization tables won't tell
> the whole story if some of the more novel pre-filtering techniques
> have been used. These (effectively) degrade the image in hopefully
> useful ways before JPEG gets a look in. You therefore cannot
> get the quality measure by just looking the JPEG numbers

You're quite right, the quantization tables are not the whole story.
There is the issue of subsampling settings (for color images), as
well as the filtering techniques that you allude to. But Aandi was
asking about determining the original quality setting assuming that
the source encoder was known. Since all JPEG encoders I know about
change the quantization tables at every quality stop (whatever else
they may change), looking at those tables should do.

paulw...@my-dejanews.com

unread,
Jul 23, 1998, 3:00:00 AM7/23/98
to
In article <uo93eck...@netcom17.netcom.com>,
Sorry, I misunderstood Aandi's question. I *though* he meant "quality".
What he meant (as you correctly answered) was "quality setting"

paulw...@my-dejanews.com

unread,
Jul 24, 1998, 3:00:00 AM7/24/98
to
In article <6ni7i2$kmp$1...@nnrp1.dejanews.com>,

paulw...@my-dejanews.com wrote:
> In article <uo93eck...@netcom17.netcom.com>,
> Tom Lane <t...@netcom.com> wrote:
> >
> > paulw...@my-dejanews.com writes:
> > > But in any case investigating the quantization tables won't tell

Sorry people, I don't know what's going on. I posted this weeks ago.

How the hell it's appeared again I do not know.

0 new messages