iPhone SDK: Wrong image orientation

Archived from the Transloadit support forum. Originally posted on May 4, 2011; details may be outdated, see our docs for current behavior. Original thread

Hi, I’m using your iPhone SDK to upload images. I followed the example and, after using the UIImageViewController to take a photo, I added the picked file like so:

[transload addPickedFile:info]; // info => the NSDictionary returned by the didFinishPickingMediaWithInfo method.

The problem is that, the result image is always in landscape mode, even if I take the picture in portrait mode.

What am I doing wrong? Is this a known issue? Can it be circumvented?

Thanks for your help.

Hey Jose,

we do support automatic rotation for miss-rotated photos, so it might be a thing specific to your situation. Can you upload the image (with all metadata on it) in here? Then we can investigate.

Kind regards,
Tim

Hey TIm,

Ok this is the step by step process of what I’m doing.

  1. Using an UIImagePickerController, I take a picture using the iPhone camera in portrait mode (just holding the iPhone in the default position).

  2. Step 1 triggers the didFinishPickingMediaWithInfo:(NSDictionary*)info delegate method. The info dictionary contains the following data:

{
    UIImagePickerControllerMediaMetadata =     {
        DPIHeight = 72;
        DPIWidth = 72;
        Orientation = 6;
        "{Exif}" =         {
            ColorSpace = 1;
            DateTimeDigitized = "2011:05:05 10:25:36";
            DateTimeOriginal = "2011:05:05 10:25:36";
            PixelXDimension = 1536;
            PixelYDimension = 2048;
        };
        "{TIFF}" =         {
            DateTime = "2011:05:05 10:25:36";
            Make = Apple;
            Model = "iPhone 3GS";
            Software = "4.3.3";
            XResolution = 72;
            YResolution = 72;
        };
    };
    UIImagePickerControllerMediaType = "public.image";
    UIImagePickerControllerOriginalImage = "<UIImage: 0x455aff0>";
}

Notice the Orientation value, which is 6 => Portrait.

  1. I create a TransloaditRequest object, and add the picked file info like so: [transload addPickedFile:info]. The template I use does the following:
{ "steps": {
    "small": {
      "robot": "/image/resize",
      "use": ":original",
      "width": 190,
      "height": 256
    },
    "export": {
      "robot": "/s3/store",
      "use": "small",
      "key": "...",
      "secret": "...",
      "bucket": "...",
      "path": "${previous_step.name}.jpg"
    }
} }
  1. When the request finishes and all is done, the image stored in our S3 bucket is in landscape (left) orientation.

Is there a way I can manipulate the image before adding it to the TransloaditRequest object?

Thanks for your help.

Hm that sounds weird.

Can you attach the image in question to this support ticket? Then I can check its exif data to see if it contains a format that we do not recognize for the auto-rotation.

Thanks
Tim

I’ve attached the images. Thanks

Hm, both show as portrait images for in the browser.

Are you sure, these are the right images?

Well, when attached here, somehow it was converted to the correct orientation, but the original file is incorrect. See attachment. Thanks.

Tim,

I managed to fix the issue by following these instructions:
http://stackoverflow.com/questions/4989087/uiimagepickercontroller-returning-incorrect-image-orientation

For the record, I’m replacing the original image returned by the UIImagePickerController with the one processed using the UIImage+Resize class mentioned in the above link; and then I’m sending the latter in the TransloaditRequest.

Thanks for your help.

Great to hear!

Kind regards,
Tim

Jose: Is this something that would be convenient for you if it was done by our SDK? If so, feel free to make the change in a fork of the SDK and I’ll merge it in!

Closing this for now.

Jose, please feel free to reopen the ticket if you are going to reply to Felix’ question.

Btw, we also support auto-rotation fixes for images now.

Thank you! Sorry for not replying before. I will try the new sdk, to see if my fix is no longer necessary.

Great. Closing this now.