Search code examples
iosobjective-cextractphlivephoto

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.


Solution

  • 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;
    }];