INDGIFPreviewDownloader
retrieves preview images for animated GIF files by downloading only the first frame. Compared to downloading the entire GIF file to create a preview image, this solution saves a huge amount of bandwidth.
Try it out using the included example app!
self.downloader = [[INDGIFPreviewDownloader alloc] initWithURLSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[self.downloader downloadGIFPreviewFrameAtURL:[NSURL URLWithString:@"http://i.imgur.com/irqjHqT.gif"] completionQueue:dispatch_get_main_queue() completionHandler:^(UIImage *image, NSError *error) {
self.imageView.image = image;
}];
downloader = INDGIFPreviewDownloader(URLSessionConfiguration: NSURLSessionConfiguration.defaultSessionConfiguration())
downloader.downloadGIFPreviewFrameAtURL(NSURL(string: "http://i.imgur.com/irqjHqT.gif")!, completionQueue: dispatch_get_main_queue()) { (image, error) in
self.imageView.image = image
}
INDGIFPreviewDownloader
initiates a download of the raw GIF data and attempts to find a complete image data block (in accordance with the GIF spec) every time new data is received. Once enough data is available to extract an image, the download is cancelled.
- Indragie Karunaratne
- @indragie
- http://indragie.com
INDGIFPreviewDownloader
is licensed under the MIT License.