Question

I am trying to crop image by my custom cropper. Not from the UIImagePickerController's. Now for that I am showing the Image captured from Image Picker in a UIImgeView by handling UIImagePicker's delegate:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    imvOriginalImage.image = image;
}

For cropping I have to convert this Image to CGImageRef. The Image is captured in portrait mode. Now when I convert this image in CGImageRef image orientation get changed. Even if I use following:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
    //imvOriginalImage.image = image;
    CGImageRef imgRef = [image CGImage];
    UIImage *img = [UIImage imageWithCGImage:imgRef];
    [imvOriginalImage setImage:img];

}

Image Orientation get changed. This happens only for those Image which are captured in portrait mode. Landscape images not have this issue.

  1. Why this is happening?
  2. How to solve this?

Thanks In Advance.

Was it helpful?

Solution

This is that iPhone camera rotates the image comparing with Home button. It uses EXIF that is meta data of image. See this thread:

iPhone image rotation

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top