https://github.com/zadr/clicktogif
A NSOperation subclass that builds a UIImage out of the first frame of an animated GIF.
https://github.com/zadr/clicktogif
Last synced: 12 months ago
JSON representation
A NSOperation subclass that builds a UIImage out of the first frame of an animated GIF.
- Host: GitHub
- URL: https://github.com/zadr/clicktogif
- Owner: zadr
- License: bsd-2-clause
- Created: 2013-09-24T02:17:08.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2015-10-28T23:05:42.000Z (over 10 years ago)
- Last Synced: 2025-01-30T11:14:06.425Z (about 1 year ago)
- Language: Objective-C
- Size: 3.51 MB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Download the first frame of an animated gif, instead of the full thing.
example usages:
```swift
func example() {
let url = NSBundle.mainBundle().URLForResource("puppy", withExtension: "gif")!
let operation = CQIntroductoryGIFFrameOperation(URL: url)
// note: `completionBlock` is also available from NSOperation, although it
// works based off of KVO states, and will take an extra runloop or two to fire.
operation.target = self
operation.action = "gifProcessed:"
NSOperationQueue.mainQueue().addOperation(operation)
}
@objc func gifProcessed(operation: CQIntroductoryGIFFrameOperation) {
if let image = operation.introductoryFrameImageData {
print("we have a still image of the first frame of an animated gif!")
}
}
```
or
```swift
func example() {
let url = NSBundle.mainBundle().URLForResource("puppy", withExtension: "gif")!
let operation = CQIntroductoryGIFFrameOperation(URL: url)
operation.completionBlock = {
if let image = operation.introductoryFrameImageData {
print("we have a still image of the first frame of an animated gif!")
}
}
NSOperationQueue.mainQueue().addOperation(operation)
}
```
(Or go straight to the code, in CQIntroductoryGIFFrameOperationHarness/CQIntroductoryGIFFrameOperation{.h, .m}.)