I'm passing stored image and video files to:
PHLivePhoto.requestLivePhotoWithResourceFileURLs
and getting a PHLivePhoto
object that I can display in PHLivePhotoView
. But I am wondering, once I have a PHLivePhoto
is there a way to save it to the Photo Library?
Once you've picked your photo, tap on the “Share” icon in the lower left-hand corner of your screen. On the shared menu, scroll past the suggested contacts and apps section to find and tap the menu item titled “Save as Video.” Your iPhone will process your request in a moment.
Select the "Photos" icon, find the Live Photos you want to backup to your computer, and download the two files, JPG and MOV, to your computer. Then you complete importing Live Photos to PC with iCloud. You can upload iPhone Live Photos to iCloud Photos, then import them to your computer and save them.
In iOS 13, 14, and 15, an option in the Photos app — Save as video — facilitates saving a Live Photo as a video with a single tap, no third-party app needed. Step 1: In the Photos app, tap the Album icon and select Live Photos. Step 2: Open a Live Photo in the gallery.
NSURL *photoURL = ...;
NSURL *videoURL = ...;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetCreationRequest *request = [PHAssetCreationRequest creationRequestForAsset];
//These types should be inferred from your files
//PHAssetResourceCreationOptions *photoOptions = [[PHAssetResourceCreationOptions alloc] init];
//photoOptions.uniformTypeIdentifier = @"public.jpeg";
//PHAssetResourceCreationOptions *videoOptions = [[PHAssetResourceCreationOptions alloc] init];
//videoOptions.uniformTypeIdentifier = @"com.apple.quicktime-movie";
[request addResourceWithType:PHAssetResourceTypePhoto fileURL:photoURL options:nil /*photoOptions*/];
[request addResourceWithType:PHAssetResourceTypePairedVideo fileURL:videoURL options:nil /*videoOptions*/];
} completionHandler:^(BOOL success, NSError * _Nullable error) {
NSLog(@"success? %d, error: %@",success,error);
}];
Swift 3:
PHPhotoLibrary.shared().performChanges({
let request = PHAssetCreationRequest.forAsset()
request.addResource(with: .photo, fileURL: photoURL, options: nil)
request.addResource(with: .pairedVideo, fileURL: videoURL, options: nil)
}) { (success, error) in
print(success)
print(error?.localizedDescription ?? "error")
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With