Search code examples
swiftphassetios13phimagemanager

ios13 get original image using PHImageManager


on ios 13 PHImageManagerMaximumSize does not work.

when calling

let manager = PHImageManager.default()
let option = PHImageRequestOptions()
option.isSynchronous = synchronous
option.isNetworkAccessAllowed = true
option.resizeMode = .exact

manager.requestImage(for: asset, targetSize: PHImageManagerMaximumSize, contentMode: .aspectFill, options: option, resultHandler: {(result, info) in
})

requestImage returns an error: Error Domain=NSCocoaErrorDomain Code=-1 "(null)"

This code runs fine on ios12

Can you please let me know how to get the original image on ios13?


Solution

  • As quoted from Apple's Documentation here:

    When you use the PHImageManagerMaximumSize option, Photos provides the largest image available for the asset without scaling or cropping. (That is, it ignores the resizeMode option.)

    However in this case, resizeMode seems to be in effect on iOS 13.

    Setting resizeMode to .none makes PHImageManagerMaximumSize work as expected.