Bug 8949 - UIImage rotating unexpectedly
Summary: UIImage rotating unexpectedly
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-12-14 19:17 UTC by Bryan Moulton
Modified: 2013-12-05 18:36 UTC (History)
3 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Bryan Moulton 2012-12-14 19:17:46 UTC
In reference to case 21206

When trying to flip an image vertically, it gets rotated 90 degrees counterclockwise. I found that the problem would come from UIImagePicker.

Below is snippet code. Input is UIImage from UIImagePicker.

The problem happens when I pick the photo that has size 1936x2592. It works
fine with size 320x480.

I can see the problem on both Simulator and Device.

public void LoadImage (UIImage image)


RectangleF rect = UIScreen.MainScreen.Bounds;

Console.WriteLine ("Crop " + rect.Width + "x" + rect.Height);


var ctx = UIGraphics.GetCurrentContext();

ctx.TranslateCTM(0f, rect.Height);

ctx.ScaleCTM(1.0f, -1.0f);

RectangleF drawSource = new RectangleF(0, 0, rect.Size.Width,

RectangleF inRect = new RectangleF(0, 0, rect.Size.Width/0.1f,

ctx.DrawImage (drawSource, image.CGImage.WithImageInRect(inRect));

UIImage finalImage = UIGraphics.GetImageFromCurrentImageContext();


finalImage.SaveToPhotosAlbum( delegate(UIImage image2, NSError error) {

Console.WriteLine("image saved to Photos");

} );

Comment 1 Sebastien Pouliot 2012-12-17 09:51:00 UTC
I have an app that uses very large images (bigger than the size mentioned above) and rotate them without any issue.

That sounds like an image issue, e.g. an photo taken in landscape where only the EXIF data knowns the orientation. This is why the "smaller" image does not behave like this. The image properties likely needs to be checked before doing the rotation.

Bryan, can you get a full sample that include the image ?
Comment 3 Sebastien Pouliot 2012-12-18 16:38:44 UTC
I suspect this happens when you take landscape (versus portrait) images with your phone. The image itself is the same size, but the orientation will be part of the metadata (e.g. EXIF). In such case you can query that data before doing your rotation.

You can try this by taking pictures on both orientations - then see if one rotates correctly.
Comment 4 PJ 2013-11-19 17:06:00 UTC
This bug has been in the NEEDINFO state with no changes for the last 90 days. Can we put this back into the NEW or CONFIRMED state, or are we still awaiting response?

If there is no change in the status of this bug over the next two weeks, this bug will be marked as NORESPONSE.
Comment 5 PJ 2013-12-05 18:36:29 UTC
This bug has not been changed from the NEEDINFO state since my previous comment, marking as RESOLVED NORESPONSE.

Please feel free to REOPEN this bug at any time if you are still experiencing the issue. Please add the requested information and set the bug back to the NEW (or CONFIRMED) state.