Save UIImage, Load it in Wrong Orientation
Check the EXIF information for the image that you're loading, there should be a tag for orientation. Use the value to rotate your image to proper orientation.
This website should get you started.
http://www.impulseadventure.com/photo/exif-orientation.html
(The application you used to view the photo must have this built in, that's why you see correct orientation when opening the photo)
The root cause is PNG format doesn't have image orientation information, but JPEG format does. So the easiest way to solve this problem is saving your file in JPEG format using UIImageJPEGRepresentation()
I have faced similar problem and here is how I solved it.
While we save image we need to save its orientation information along with the image ...
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setInteger:[myImage imageOrientation] forKey:@"kImageOrientation"];
[imageOrientation release];
And we load image we need to read its orientation information and apply it to the image…
UIImage *tempImage = [[UIImage alloc] initWithContentsOfFile:fullPath];
UIImage *orientedImage= [[UIImage alloc] initWithCGImage: tempImage.CGImage scale:1.0 orientation:imageOrientation];
[tempImage release];
orientedImage
is what we need.
Thanks,