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

iOS camera service saves photo with inncorrect orientation metadata

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P2: Important
    • None
    • 5.3.1, 5.4.0
    • Multimedia
    • iPad 2, Ubuntu 14.10, x64
    • iOS/tvOS/watchOS

    Description

      There was a QTBUG-38106 that was closed as invalid, but I am not sure that everything is so simple there.
      It seams that at least on iPad 2 image from camera is saved without metadata (or with corrupted/invalid metadata).

      That bug description says that photo preview and saved photo has different orientation.
      But it is impossible if we look at the implementation here: https://qt.gitorious.org/qt/qtmultimedia/source/c93d83c4b7a5d1a5d7b35d93141d96abaf58ed7e:src/plugins/avfoundation/camera/avfimagecapturecontrol.mm#L115
      You see, preview and final image are made from the same buffer nsJpgData. It may or may not contain orientation metadata.

      Both preview and final image are generated using Qt classes which are not aware of metadata (QImageReader and QFile).
      So, if nsJpgData contains valid orientation metadata, it will be saved.

      I am not sure how to check this, but I've tried to open saved image using few EXIF tools and they all reported that there is no EXIF information in the file.
      So, I do not know how to check nsJpgData, but it is quite simple to read metadata from imageSampleBuffer.
      I did the following:
      CFDictionaryRef metadata = CMCopyDictionaryOfAttachments(NULL, imageSampleBuffer, kCMAttachmentMode_ShouldPropagate);
      NSLog(@"%@", metadata);
      The output was:
      {
      Orientation = 6;
      "

      {Exif}

      " =

      { ApertureValue = "2.526068811667588"; BrightnessValue = "2.714162053702216"; ExposureBiasValue = 0; ExposureMode = 0; ExposureProgram = 2; ExposureTime = "0.0303030303030303"; FNumber = "2.4"; Flash = 32; FocalLenIn35mmFilm = 35; FocalLength = "1.85"; ISOSpeedRatings = ( 125 ); LensMake = Apple; LensModel = "iPad 2 front camera 1.85mm f/2.4"; LensSpecification = ( "1.85", "1.85", "2.4", "2.4" ); MeteringMode = 5; PixelXDimension = 640; PixelYDimension = 480; SceneType = 1; SensingMethod = 2; ShutterSpeedValue = "5.058893689053568"; WhiteBalance = 0; }

      ;
      "

      {MakerApple}

      " = {
      1 = 2;
      3 =

      { epoch = 0; flags = 1; timescale = 1000000000; value = 1799868571232500; }

      ;
      4 = 1;
      5 = 200;
      6 = 192;
      7 = 1;
      8 = (
      "-0.005150147",
      "-0.01196241",
      "-1.007714"
      );
      };
      }
      So, first of all Orientation is outside of Exif metadata, so there is no guarantee that it will be saved and later read by EXIF tool or library.
      But there is also even more serious problem: Orientation is always 6! It doesn't depend on device orientation and even from active camera (front/back)

      Taking all these into account I just cannot understand how this implementation may work.

      From my point of view Qt should

      • either use iOS API for saving the photo to be sure that all metadata are stored properly
      • or handle orientation itself and rotate the data.

      I have implemented the latest variant and it works perfectly. See attached patch bellow

      Attachments

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

        Activity

          People

            valentyn.doroshchuk Valentyn Doroshchuk
            korvin Stepan Prokipchyn
            Votes:
            8 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes