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

Jpeg image plugin can not read some jpeg files without exif infomation.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Duplicate
    • Affects Version/s: 5.5.0
    • Fix Version/s: None
    • Component/s: Image formats
    • Labels:
      None

      Description

      the jpeg image format plugin can not read jpg file without exif info or without exif orientation info. refer to the attachment.

      The problem is:
      1, in bool QJpegHandlerPrivate::read(QImage *image)
      Only if "State==ReadHeader', then it will read the jpeg contents.

      But
      2, in bool QJpegHandlerPrivate::readJpegHeader(QIODevice *device)

      if (exifOrientation == -1)
      return false;

      At that time, even if the file is a valid jpg, if it does not contain any exif infos or does not contain exifOrientation infos, it will retrun directly and leave "state" not set to "ReadHeader".

      Here is a patch to fix it:
      diff -Nur qtbase-opensource-src-5.5.0/src/gui/image/qjpeghandler.cpp qtbase-opensource-src-5.5.0n/src/gui/image/qjpeghandler.cpp
      — qtbase-opensource-src-5.5.0/src/gui/image/qjpeghandler.cpp 2015-06-29 20:04:51.000000000 +0000
      +++ qtbase-opensource-src-5.5.0n/src/gui/image/qjpeghandler.cpp 2015-08-13 20:41:32.187145848 +0000
      @@ -900,7 +900,8 @@
      size = QSize(width, height);

      format = QImage::Format_Invalid;

      • read_jpeg_format(format, &info);
        + if(read_jpeg_format(format, &info))
        + state = ReadHeader;

      QByteArray exifData;

      @@ -935,7 +936,6 @@
      transformation = exif2Qt(exifOrientation);
      }

      • state = ReadHeader;
        return true;
        }
        else

      if "file is a valid jpg file" and be supported, then set "state" to "ReadHeader".

      And the jpeghandler codes still need more improvements, for example:
      "readJpegHeader" had a "bool' retrun value but the value is never used.

      Actually, the existence and use of "ReadHeader" state is awkward and almost useless.

        Attachments

        1. 123.jpeg
          10 kB
          Cjacker Huang

          Issue Links

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

            Activity

              People

              Assignee:
              vgt Eirik Aavitsland
              Reporter:
              cjacker Cjacker Huang
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes