Simple iOS Swift WebP decoder to UIImage. The project use a standalone version of WebP library, without the use of cocoapods (or other dependency managers) to avoid problems with swift dynamic libraries.
- Download the precompiled library from Google Developers
- Unzip the .tar.gz file and rename it: "WebP.framework" and put it in the project folder
- Open Xcode project, target 'app', Build Phases and click "Other Framework" in Link Binary with Libraries
- Select 'WebP.framework'
- Add in your bridging header the reference to the WebP framework:
#import "webp/decode.h"
- Include 'UIImage+WebPDecoder.swift' in your project
- Enjoy WebP Decoder 😃
//Example
let url = URL(string: "https://www.gstatic.com/webp/gallery3/3_webp_ll.webp")!
//Simple Usage without options
let imageWithURL = UIImage(webpWithURL: url)
//Simple Usage Example with options
let options: [String : Int32] = ["no_fancy_upsampling":1,"bypass_filtering":1,"use_threads":1]
let imageWithURLandOptions = UIImage(webpWithURL: url, andOptions: options)
//From URL
let image = UIImage(webpWithURL: URL)
let image = UIImage(webpWithURL: URL, andOptions: [String:Int32])
//From path
let image = UIImage(webpWithPath: String)
let image = UIImage(webpWithPath: String, andOptions: [String:Int32])
//From data
let image = UIImage(webpWithData: NSData)
let image = UIImage(webpWithData: NSData, andOptions: [String:Int32])
- WebP Library by Google
- "PNG transparency demonstration" photo licensed under the Creative Commons Attribution-Share Alike 3.0 Unported license by POV-Ray source code.