• Stars
    star
    158
  • Rank 237,131 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 8 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A think libwebp wrapper in Swift that provides both encode/decode APIs

Swift-WebP

Build Status Carthage compatible

Swift Wrapper of libwebp

Target

Swift-WebP aims to deal with image processing flexibly for WebP format in Swift unlike an image loading library; such as SDWebImage. So this library allows you to use many features libwebp has without hassles to use C API from Swift. And also you don't need to install libwebp by yourself if you install this via Carthage. This contains it inside the framework.

Support Versions:

  • libwebp: v1.0.3
  • iOS Deployment Target: 8.0
  • macOS Deployment Target: 10.11

Features

  • Support mutiplatform; iOS, macOS, and Linux (swift-docker)
  • Support SPM
  • Advanced Encoder API - WebPEncoder, WebPEncoderConfig
  • Advanced Decoding API - WebPDecoder, WebPDecoderOptions
  • Image inspection for WebP files - WebPImageInspector

TODO

  • Progressively encoding/decoding option
  • Animated WebP

Usage

Encoding

let image = UIImage(named: "demo")
let encoder = WebPEncoder()
let queue =  DispatchQueue(label: "me.ainam.webp")

// should encode in background
queue.async {
    let data = try! encoder.encode(image, config: .preset(.picture, quality: 95))
    // using webp binary data...
}

Decoding

let data: Data = loadWebPData()
let encoder = WebPDecoder()
let queue =  DispatchQueue(label: "me.ainam.webp")

// should decode in background
queue.async {
    var options = WebPDecoderOptions()
    options.scaledWidth = Int(originalWidth / 2)
    options.scaledHeight = Int(originalHeight / 2)
    let cgImage = try! decoder.decode(data, options: options)
    let webpImage = UIImage(cgImage: cgImage)

    DispatchQueue.main.async {
        self.imageView.image = webpImage
    }
}

Example

Please check example projects

Installation

This library won't support CocoaPods. It's difficult to create and maintain podspec files for static libraries. (But contribution for that is always welcome.)

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate WebP into your Xcode project using Carthage, specify it in your Cartfile:

github "ainame/Swift-WebP"

Run carthage update --use-submodules to build the framework and drag the built `WebP.framework** into your Xcode project.

Don't forget to use --use-submodules flag!

Author

ainame

License

Swift-WebP is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

FrameKit

A Swift library that helps you build stunning App Store screenshots with SwiftUI
Swift
41
star
2

motion-mode

motion-mode.el is a package to provide emacs' major mode for RubyMotion enviroment.
Ruby
38
star
3

smart-newline.el

The smart-newline.el provide a stress-less newline command for programmer.
Emacs Lisp
33
star
4

Swift-Daemon

daemonize your swift scripts
Swift
23
star
5

Lumpik

[experimental] Lumpik is a job queue system for general purpose.
Swift
21
star
6

Shiori

Shiori is a github viewer in iPad. This manage your bookmarks(it is called shiori in Japanese) .
Ruby
20
star
7

mediakit

mediakit is the libraries for ffmpeg and sox backed media manipulation something.
Ruby
14
star
8

rixi

Rixi is a simply library for mixi graph api in Ruby.
Ruby
12
star
9

motion-my_env

motion-my_env is a simple environment managing solution on RubyMotion app.
Ruby
9
star
10

emacs-d

my emacs configuration
Emacs Lisp
8
star
11

explain_parser

A simple library to deal with the result of EXPLAIN query in MySQL; inspired by http://search.cpan.org/~moznion/MySQL-Explain-Parser-0.02/lib/MySQL/Explain/Parser.pm
Ruby
7
star
12

AMEURLSession

AMEURLSession provide the simple and customizable interface of NSURLSession family classes to easy using.
Objective-C
6
star
13

bitrise-step-rbenv

Un-official Bitrise step library to install a Ruby version via rbenv with the automatic cache path collection for the official Cache-Push step
Shell
6
star
14

p5-Test-More-Hooks

Test::More::Hooks provide before/after hooks for each subtest test cases.
Perl
5
star
15

cursor-test.el

cursor-test.el is the testing library for cursor position in emcas lisp.
Emacs Lisp
4
star
16

AMEAspectSpeedometer

AMEAspectSpeedometer provide a solusion of velocity measurement in your application code.
Objective-C
4
star
17

Motion-iOSTraning-Self-Study

see https://github.com/mixi-inc/iOSTraining
Ruby
4
star
18

activerecord-bit_field

activerecord-bit_field provide a feature of mapping bit fileds to RDB table in ActiveRecord.
Ruby
3
star
19

hjkl-mode

hjkl-mode is a minor-mode on emacs. It provides vim keybindings for moving cursor.
Emacs Lisp
3
star
20

github-daily_deploy

CLI tool for daily deployment workflow by github flow which have production branch.
Ruby
2
star
21

dogen

Dogen is the wrapper of template engine for building evalution enviroment without Web Application Framework.
Ruby
2
star
22

kietter

Twitter likeなインターフェイスから独り言を呟くためのツールです。Memcachedを利用して60秒で投稿が消えるようになってます。
Ruby
2
star
23

motion-with-rails-sample

This is sample code repository. This provide simple Client-Server model on RubyMotion and Rails.
Ruby
2
star
24

idiary

ハッカソンで作ってみようと思って途中でタイムアップしてしまったアプリケーションです。consumer keyとかgべた書きしてますが失効してます。
JavaScript
2
star
25

mixer

音声+SE合成アプリ
Swift
1
star
26

git_reporter

git_reporter let you are able to grasp history of the huge git repository.
Ruby
1
star
27

foursquare-module

the part of foursquare API wrapper module
Ruby
1
star
28

hyperscan-Swift

[WIP] A Swift binding library of intel/hyperscan
Swift
1
star
29

ainame.github.com

blog
1
star
30

may

[WIP] may is a CLI tools for generating Objective-C based class files to a Xcode project.
Ruby
1
star
31

Katakanaize

Katakanaize is a rack middleware to convert hiragana to katakana.
Ruby
1
star
32

fastlane-plugin-frameit_rtl_support

This is an experiment that makes frameit support Arabic. (Not published to rubygems.org yet)
Ruby
1
star
33

postbot

postbot deliver many articles of fresh news.
Ruby
1
star
34

Nikki

mixi日記を書くためのツールです
JavaScript
1
star
35

motion-boilerplate

The collection of my boilerplate to create RubyMotion apps quickly.
Ruby
1
star
36

photo-kit-sample

Objective-C
1
star
37

INMEnum

INMEnum provide defining method to create a enum object as a plain old objc object.
Objective-C
1
star
38

pebbles-suddenly_death

pebbles-suddenly_death is a joke gem.
Ruby
1
star
39

StoreKitTestingProxy

A component for PoC to implement StoreKit Testing support in maestro
Objective-C
1
star