Fix image orientation + iphone
I am using the camera function in my application and save the images to the document directory after clicking on the photo. Whenever I use images, the orientation of those images changes. So for this I search on stackoverflow and get the solution from this link:
iOS UIImagePickerController - Result of image orientation after loading
But I can't figure out how to use the fix orientation method to get the original orientation of the image. If anyone knows about this please help me.
Thanks everyone.
source to share
-
Add this category to your project
UIImage + fixOrientation
or you can create it manually using the links below.
[1]: [code for UIImage + FixOrientation.h]
https://github.com/j3r3miah/mapmatic-ios/blob/master/Mapmatic/UIImage+FixOrientation.h
[2]: [code for UIImage + FixOrientation.m]
https://github.com/j3r3miah/mapmatic-ios/blob/master/Mapmatic/UIImage+FixOrientation.m
After creating this category, import it into your view controller,
import "UIImage + fixOrientation.h"
and implement this delegate UIImagePickerController
- (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info { UIImage *myimage = [info objectForKey: UIImagePickerControllerOriginalImage]; myimage=myimage.fixOrientation; } This fixOrientation method would fix the image orientation in portrait mode.
source to share