3

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?

Nemo
  • 587
  • 6
  • 12
  • I'm experiencing the same, although when I request for the thumbnail size image it worked. In fact if you specify any size other than PHImageManagerMaximumSize it'll work. Maybe it's the targetSize issue? btw I don't think it's an issue of deprecated API. It's the same even with code build with iOS12 SDK on iOS13 device. – Bonan Sep 19 '19 at 00:35

4 Answers4

8

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.

Schinizer
  • 306
  • 3
  • 9
0

Try requestImageDataForAsset, even though its marked as deprecated. You should also report the requestImage issue on iOS 13 to Apple as a bug.

holtmann
  • 6,043
  • 32
  • 44
0

For those that are still having problems requesting the original image on iOS 13 try using requestImageDataAndOrientation instead.

The docs Suggest that this is the correct way to request the original image data. It returns NSData that you can create an UIImage with if you need that.

-2

requestImageDataForAsset is deprecated. zoption.isSynchronous = Yes` would not work in iOS 13.

Juri Noga
  • 4,363
  • 7
  • 38
  • 51
  • 3
    Deprecated doesn't mean, that it does not work anymore. It means that there is a new API you are preferred to use instead and it might be removed in a future release of iOS 13. requestImageDataForAsset still does fully work in iOS 13 in my testing. – holtmann Sep 02 '19 at 10:12