2

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.

Community
  • 1
  • 1
Utsav Dusad
  • 2,139
  • 4
  • 31
  • 52

2 Answers2

4

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;
}];
Dean
  • 939
  • 10
  • 30
0

You can also write an image data to file path, just like with video in your question. Both asset resources are available in live photo asset (video & image):

 let resources = PHAssetResource.assetResources(for: asset)
Andrey Zhukov
  • 61
  • 1
  • 5