Converting UIImage to CGImage Rotates the Image

I am trying to crop an image using my custom cropper. Not from UIImagePickerController. Now for this, I show the image taken from the Image Picker in a UIImgeView, processing the UIImagePicker 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 shot in portrait mode. Now when I convert this image to CGImageRef, the orientation of the image will change. Even if I use the 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];

}

The orientation of the image will change. This only happens for those images that are recorded in portrait mode. Landscaping images do not have this problem.

  • Why is this happening?
  • How to solve this?

Thanks in advance.

+5
source
1

iPhone "". EXIF, . :

iPhone

+4

All Articles