drodriguez / STWebPDecoder

A simple Cocoa wrapper for libwebp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

STWebPDecoder

A simple wrapper for libwebp, providing a simple interface to decode WebP image data for use in iOS / Mac applications.

NSString * const webpPath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"webp"];
NSData * const webpData = [[NSData alloc] initWithContentsOfFile:webpPath options:NSDataReadingMappedIfSafe error:NULL];
self.imageView.image = [STWebPDecoder imageWithData:webpData scale:2 error:NULL];

STWebPURLProtocol

More interestingly, this class allows transparent use of WebP images inside UIWebViews.

[STWebPURLProtocol registerWithOptions:@{ STWebPURLProtocolOptionClaimWebPExtension: @YES }];

[self.webView loadHTMLString:@"<img src=\"https://www.gstatic.com/webp/gallery3/2_webp_ll.webp\">" baseURL:nil];

About

A simple Cocoa wrapper for libwebp

License:Mozilla Public License 2.0


Languages

Language:Objective-C 91.1%Language:Ruby 8.9%