For large images, the UIImagePickerControllerOriginalImage key does not return the original image on iOS 11.
For example, if I select a photo with a size of 6500 x 6500 pixels with the UIImagePickerController in iOS 10 and get the picture with the key UIImagePickerControllerOriginalImage, the image size is 6500 x 6500 pixels.
Under iOS 11, the image is only 2048 x 2048 pixels.
The solution:
if(picker.sourceType == UIImagePickerControllerSourceTypePhotoLibrary)
{
__block UIImage *image = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];
if (@available(iOS 11.0, *))
{
PHAsset * asset = (PHAsset*)[info objectForKey:UIImagePickerControllerPHAsset];
PHImageManager *manager = [PHImageManager defaultManager];
PHImageRequestOptions *requestOptions = [[PHImageRequestOptions alloc] init];
requestOptions.resizeMode = PHImageRequestOptionsResizeModeExact;
requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
requestOptions.synchronous = true;
[manager requestImageForAsset:asset
targetSize:PHImageManagerMaximumSize
contentMode:PHImageContentModeDefault
options:requestOptions
resultHandler:^void(UIImage *img, NSDictionary *info) {
if(img != nil)
{
image = img;
}
}];
}
// use the original image now
}