Easily convert a video to a GIF on iOS and OSX.
🚀
I also make Rocket, an app that gives you Slack-style emoji everywhere on your Mac.
Regift is available through CocoaPods, and requires Swift 2. To install it, simply add the following line to your Podfile:
pod "Regift"
Regift is available through Carthage.
github 'matthewpalmer/Regift'
import Regift
Synchronous GIF creation:
let videoURL = ...
let frameCount = 16
let delayTime = Float(0.2)
let loopCount = 0 // 0 means loop forever
let regift = Regift(sourceFileURL: videoURL, frameCount: frameCount, delayTime: delayTime, loopCount: loopCount)
print("Gif saved to \(regift.createGif())")
let startTime = Float(30)
let duration = Float(15)
let frameRate = 15
let trimmedRegift = Regift(sourceFileURL: URL, startTime: startTime, duration: duration, frameRate: frameRate, loopCount: loopCount)
print("Gif saved to \(trimmedRegift.createGif())")
Asynchronous GIF creation:
let videoURL = ...
let frameCount = 16
let delayTime = Float(0.2)
let loopCount = 0 // 0 means loop forever
Regift.createGIFFromSource(videoURL, frameCount: frameCount, delayTime: delayTime) { (result) in
print("Gif saved to \(result)")
}
let startTime = Float(30)
let duration = Float(15)
let frameRate = 15
Regift.createGIFFromSource(videoURL, startTime: startTime, duration: duration, frameRate: frameRate) { (result) in
print("Gif saved to \(result)")
}
Thanks to Rob Mayoff's Gist, without which this library wouldn't exist.
My personal thanks to all of Regift’s contributors:
- caughtinflux
- samuelbeek
- sebyddd
- nakajijapan
- dbburgess