Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract image from a live photo?

I know how to extract video from a live photo. Explained here.

Use the PHAssetResourceManager to get the video file from the PHAssetResource.

PHAssetResourceManager.defaultManager().writeDataForAssetResource(assetRes, 
    toFile: fileURL, options: nil, completionHandler: 
  {
     // Video file has been written to path specified via fileURL
  }

But how to extract image URL from PHLivePhoto. The motivation behind this is to get both video and image URL in order to upload it to the server.

like image 423
Utsav Dusad Avatar asked Jan 22 '26 20:01

Utsav Dusad


1 Answers

Well assuming you have access to the PHAsset you can do something like the following:

[asset requestContentEditingInputWithOptions:nil
                           completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {
      NSURL *imageURL = contentEditingInput.fullSizeImageURL;
}];
like image 198
Dean Avatar answered Jan 25 '26 11:01

Dean