I am uploading an image clicked from iphone both in landscape and portrait mode. The image with landscape mode is uploaded fine but the issue is with the image uploaded with
Ok, a cleaner version would be :
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *img = [info valueForKey:UIImagePickerControllerOriginalImage];
img = [UIImage imageWithCGImage:[img CGImage]];
UIImageOrientation requiredOrientation = UIImageOrientationUp;
switch ([[[info objectForKey:@"UIImagePickerControllerMediaMetadata"] objectForKey:@"Orientation"] intValue])
{
case 3:
requiredOrientation = UIImageOrientationDown;
break;
case 6:
requiredOrientation = UIImageOrientationRight;
break;
case 8:
requiredOrientation = UIImageOrientationLeft;
break;
default:
break;
}
UIImage *portraitImage = [[UIImage alloc] initWithCGImage:img.CGImage scale:1.0 orientation:requiredOrientation];
}