Is it ok to get fullSizeImageURL by requesting content editing input to share photos?

Is it ok to call requestContentEditingInput for a lot of PHAssets to get URLs for their full size image? It seems odd because I would not be using the content editing input to actually modify these images. Is that ok are or are there implications to be aware of?

Use case: I want to allow the user to share multiple PHAssets via UIActivityViewController. I can download and share an array of UIImage, which works, but I found if you tap Copy the app freezes for like 1 second for each photo (10 seconds if you shared 10 photos). Profiling the app it looks like iOS is spending the time creating a PNG for each image. Also it's probably not a good idea to store huge images in memory like that. I figured I'd try sharing an array of URLs to the images. Seemingly the only way you can get a URL for a photo is by requesting a content editing input for the asset and accessing its fullSizeImageURL property. Is this a good idea, and is this the right approach to share PHAssets?

Replies

Hello,

Have you looked at PHAssetResourceManager? I think this might be more appropriate for what you are trying to do: https://developer.apple.com/documentation/photokit/phassetresourcemanager/1616279-requestdata

  • Thanks, this is what I’m using now, I then convert that data to a UIImage to share, but this has several problems noted above :)

  • You said: "I'd try sharing an array of URLs to the images. Seemingly the only way you can get a URL for a photo is by requesting a content editing input for the asset and accessing its fullSizeImageURL property. Is this a good idea, and is this the right approach to share PHAssets?"

    Have you tried just share the returned image Data from the requestData method? This approach (just like with URLs) would also not require loading the image in memory.

  • I ended up using PHAssetResource to get the resource then call PHAssetResourceManager.writeData to save the image to a temporary file. That way I can still share an array of file URLs. Nice thing about this is it shows metadata in the share sheet, most useful when sharing a single file.

Add a Comment