LPLivePhotoGenerator
A Swift library for creating and saving Live Photos
Installation
CocoaPods Dependency:
As aAdd the following to your Podfile:
pod 'LPLivePhotoGenerator'
cd
into the directory where your Podfile is present and install
pod install
Manual Installation (Framework):
- Drag the
LPLivePhotoGenerator.xcodeproj
file into your Xcode project. - Add
LPLivePhotoGenerator.framework
to "Embedded Binaries" in the "General" tab of your target.
Usage
1. Import LPLivePhotoGenerator
Import LPLivePhotoGenerator module wherever you want to use it:
import LPLivePhotoGenerator
2. Creating and Saving a Live Photo:
// Create a LivePhoto object with a image path and video path
LPLivePhotoGenerator.create(inputImagePath: imagePath, inputVideoPath: videoPath) { (livePhoto: LPLivePhoto?, error: Error?) in
// Unwrap object
if let livePhoto = livePhoto {
// Set the Live Photo in a PHLivePhotoView
let livePhotoView = PHLivePhotoView(frame: rect)
livePhotoView.livePhoto = livePhoto
// Save Live Photo to Photo Library
livePhoto.writeToPhotoLibrary(completion: { (livePhoto: LPLivePhoto, error: Error?) in
if error == nil {
...
}
})
}
}
3. Extra Tool (LPLivePhoto Method):
// Move paired image and video to new path
livePhoto.movePairedImageAndVideoTo(path: path, completion: { (success: Bool, error: Error?) in
if success {
...
}
})
Demo Application
The "Demo" is a basic reference application created to show how to install LPLivePhotoGenerator using CocoaPods and develop applications using this library.
Installation
CocoaPods should be installed before continuing. To access the project, run the following:
git clone --recursive https://github.com/OlegAba/LPLivePhotoGenerator.git
cd LPLivePhotoGenerator/Demo/
pod install
open Demo.xcworkspace
You can also check out SuperSnapcode - an open-source iOS application that is built using this library
License
This project is licensed under the MIT License - see the LICENSE file for details