Latest 0.2.3
Homepage https://github.com/SDWebImage/SDWebImageWebPCoder
License MIT
Platforms ios 8.0, osx 10.10, tvos 9.0, watchos 2.0
Dependencies SDWebImage/Core, libwebp
Authors

CI Status
Version
License
Platform
Carthage compatible

Starting with the SDWebImage 5.0 version, we moved the WebP support code and libwebp from the Core Repo to this stand-alone repo.

SDWebImageWebPCoder supports both WebP decoding and encoding, for Static WebP or Animated WebP as well.

Requirements

  • iOS 8
  • macOS 10.10
  • tvOS 9.0
  • watchOS 2.0

Installation

CocoaPods

SDWebImageWebPCoder is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SDWebImageWebPCoder'

Carthage

SDWebImageWebPCoder is available through Carthage.

github "SDWebImage/SDWebImageWebPCoder"

Usage

  • Objective-C
// Add coder
SDImageWebPCoder *webPCoder = [SDImageWebPCoder sharedCoder];
[[SDImageCodersManager sharedManager] addCoder:webPCoder];

// WebP image loading
UIImageView *imageView;
NSURL *webpURL;
[imageView sd_setImageWithURL:webpURL];

// WebP image encoding
UIImage *image;
NSData *webpData = [[SDImageWebPCoder sharedCoder] encodedDataWithImage:image format:SDImageFormatWebP options:nil];
  • Swift
// Add coder
let WebPCoder = SDImageWebPCoder.shared
SDImageCodersManager.shared.addCoder(WebPCoder)

// WebP online image loading
let webpURL: URL
let imageView: UIImageView
imageView.sd_setImage(with: webpURL)

// WebP image encoding
let image: UIImage
let webpData = SDImageWebPCoder.shared.encodedData(with: image, format: .webP, options: nil)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

This is a demo to show how to use WebP and animated WebP images via SDWebImage.

Screenshot

These WebP images are from WebP Gallery and GIF vs APNG vs WebP

Author

Bogdan Poplauschi
DreamPiggy

License

SDWebImageWebPCoder is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SDWebImageWebPCoder",
    "version": "0.2.3",
    "summary": "WebP decoder/encoder for SDWebImage coder plugin.",
    "description": "This is a SDWebImage coder plugin to support WebP image.",
    "homepage": "https://github.com/SDWebImage/SDWebImageWebPCoder",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Bogdan Poplauschi": "[email protected]"
    },
    "source": {
        "git": "https://github.com/SDWebImage/SDWebImageWebPCoder.git",
        "tag": "0.2.3"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.10",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "module_map": "SDWebImageWebPCoder/Module/SDWebImageWebPCoder.modulemap",
    "source_files": [
        "SDWebImageWebPCoder/Classes/**/*",
        "SDWebImageWebPCoder/Module/SDWebImageWebPCoder.h"
    ],
    "xcconfig": {
        "GCC_PREPROCESSOR_DEFINITIONS": "$(inherited) SD_WEBP=1",
        "USER_HEADER_SEARCH_PATHS": "$(inherited) $(SRCROOT)/libwebp/src"
    },
    "watchos": {
        "xcconfig": {
            "GCC_PREPROCESSOR_DEFINITIONS": "$(inherited) SD_WEBP=1 WEBP_USE_INTRINSICS=1",
            "USER_HEADER_SEARCH_PATHS": "$(inherited) $(SRCROOT)/libwebp/src"
        }
    },
    "dependencies": {
        "SDWebImage/Core": [
            "~> 5.0"
        ],
        "libwebp": [
            "~> 1.0"
        ]
    }
}

Pin It on Pinterest

Share This