Results 1 to 7 of 7

Thread: QImage and JPEG compression-level

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Posts
    73
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    16
    Thanked 3 Times in 3 Posts

    Default QImage and JPEG compression-level

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: QImage and JPEG compression-level

    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

  3. #3
    Join Date
    Jan 2006
    Posts
    73
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    16
    Thanked 3 Times in 3 Posts

    Default Re: QImage and JPEG compression-level

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QImage and JPEG compression-level

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Frankfurt, Germany
    Posts
    34
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default Re: QImage and JPEG compression-level

    here is some more information:
    http://lists.apple.com/archives/Quic.../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.

  6. #6
    Join Date
    Jan 2006
    Posts
    73
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    16
    Thanked 3 Times in 3 Posts

    Default Re: QImage and JPEG compression-level

    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?

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QImage and JPEG compression-level

    Are you asking about QImage or the JFIF header?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.