PDA

View Full Version : QImage and JPEG compression-level



jcr
4th May 2007, 12:11
Hello,

I need to know the compression-level of the jpeg I am loading but I could not find a function in QImage.

Thank you
JCR

marcel
4th May 2007, 12:27
QImage does not expose such low-level details...
Hoever, there is a CompressionRatio info in QImageIOHandler. I don't know if that will give you the compression level for a jpeg, but you can try it.

It can't take you more than 5-10 minutes to see if it works.

Regards

jcr
4th May 2007, 15:05
Hello,
Thanks for the idea. Something like
QImageReader imgReader("060611 099.jpg");
qWarning() << imgReader.quality();
qWarning() << imgReader.format();
qWarning() << imgReader.size();
returns
-1
"jpeg"
QSize(640, 480)

From the doc

This is an image format specific function that sets the quality level of the image to quality. For image formats that do not support setting the quality, this value is ignored.
The value range of quality depends on the image format. For example, the "jpeg" format supports a quality range from 0 (low quality, high compression) to 100 (high quality, low compression).
This function was introduced in Qt 4.2.
I am wondering if I am doing something wrong or if there is an issue with this new feature.

wysota
4th May 2007, 15:11
Correct me if I'm wrong but there is no such thing as a quality of a JPEG image that is stored within the file. You can only set the quality while saving the image as the quality describes how much information is discarded. You can probably store the number in some generic key-value data (if JPEG has such dictionary available), but it'll be meaningless.

kiker99
5th May 2007, 14:09
here is some more information:
http://lists.apple.com/archives/QuickTime-API/2005/Jul/msg00263.html

so you won't be able to get the exact quality. You will be able to say if the jpeg is saved loss-less, otherwise you can just try to estimate.

jcr
8th May 2007, 01:04
Hello,

I asked some friend about the topic and it told me in substance that the compression level of a jpeg picture is not discarded, but is buried in the metadata (usually in the JPEGQuality field of the APP13 segment of the JFIF header). The ImageMagick command would be something like:
identify -format "%Q" ""060611 099.jpg"
It looks like that QImageReader.quality() does not get that value despite the fact the docs explicitly refers to that jpeg compression level. What could be the use of that function? To give the opportunity to the programmer to enter a value and store it?

wysota
8th May 2007, 01:16
Are you asking about QImage or the JFIF header?