iOS 11 does not return the original image for large images with UIImagePickerControllerOriginalImage

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
}

Replies

This solution works perfectly for my apps.

Unfortunately, Safari has this problem too. If I want to upload a large image with Safari, the size of the image will be reduced from 6500x6500 pixels to 2048x2048 automatically without asking.

But in business and advertising, you often need full resolution.

in the PHImageRequestOptions, did you try to set requestOptions.version = PHImageRequestOptionsVersionOriginal.

With that option set, you should see the original version.
You can try as well with the PHImageRequestOptionsVersionUnadjusted.

The PHImageManager works fine. That is not the problem. The problem is, that the UIImagePickerController does not return the original image with UIImagePickerControllerOriginalImage for large images since iOS 11.