Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-115454

QImageReader's API cannot detect if image contains corrupt data



    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15, 6.5
    • Image formats
    • None
    • Any existing Qt version (tested under Qt 5.15.10 and Qt 6.5.1)
    • All


      When reading image files via QImageReader, it's not possible to check if a curtain image can be loaded to QImage but the image itself contains corrupted data. QImageReader's API probably should be extended to cover this case.

      Currently, if we trying to load an image file via QImageReader, there can be output like `Corrupt JPEG data: premature end of data segment`, but such information cannot be fetched from the API, and 3rd-party image formats' plugin developers also cannot deliver such information to Qt itself. Thus, developers cannot verify if the image is valid via Qt's existing API.

      Step to reproduce:

      1. Download the attachment image file `1682752220029149185_F1pV4f0XgAAEtwJ.jfif` (The jfif suffix can be renamed to jpg if preferred, not affected to reproduce this issue)
      2. Write a simple demo, try use QImageReader to load and read the file.
      3. See result: image can be loaded to a QImage, but we can see a line "Corrupt JPEG data: premature end of data segment" from the application output panel.

      Related discussions:

      1. https://www.qtcentre.org/threads/19917-Loading-corrupt-jpeg-images-with-QImage
      2. https://stackoverflow.com/questions/33198296/qt-load-incomplete-jpeg-data-into-qpixmap-how-to-verify

      Let me know if any additional information is needed.


        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            vgt Eirik Aavitsland
            blumia Gary Wang
            0 Vote for this issue
            1 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes