I am trying to edit a captured Image and save it to gallery. I have made
UIImagePickerController *picker=[[UIImagePickerController alloc] init];
picker.allowsEditting=YES;
I want to save the image in the editable square portion and save it to gallery. I know i can make use of [info objectForKey:@"UIImagePickerControllerEditedImage"]
to save the editted image. But this always returns me an image of dimension 320x320(iPad Mini) and the image is of poor quality. So I planned to crop the original image [info objectForKey:@"UIImagePickerControllerOriginalImage"]
by using the following code:
CGRect rect = [[info objectForKey:@"UIImagePickerControllerCropRect"]CGRectValue];
UIImage *originalImage=[info objectForKey:@"UIImagePickerControllerOriginalImage"];
CGImageRef imageRef = CGImageCreateWithImageInRect([originalImage CGImage], rect);
UIImage *result = [UIImage imageWithCGImage:imageRef
scale:originalImage.scale
orientation:originalImage.imageOrientation];
CGImageRelease(imageRef);
Then I saved both the result image and the Edited Image ([info objectForKey:@"UIImagePickerControllerEditedImage"]
). When compared both the images, they dint match. I have attached the edited and cropped Images. My ultimate aim is to crop the original image to the image in the editable square portion and save it to gallery with good image quality. Can anyone please tell me on what exactly goes wrong here and help me fix this issue?
Thanks in advance.