Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to save a Live Photo to the Photo Library?

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?

like image 283
keegan3d Avatar asked Oct 01 '15 18:10

keegan3d


People also ask

How do I save a live photo to my gallery?

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.

Can I save live Photos to files?

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.

Can you save iPhone live Photos?

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.


2 Answers

    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);
        }];
like image 85
jlw Avatar answered Oct 08 '22 13:10

jlw


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")
    }
like image 30
carlos16196 Avatar answered Oct 08 '22 14:10

carlos16196