All Projects → ainame → Swift-WebP

ainame / Swift-WebP

Licence: MIT license
A thin Swift wrapper of libwebp to make your own encoder/decoder app

Programming Languages

swift
15916 projects
shell
77523 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Swift-WebP

go-webp
Simple and fast webp library for golang
Stars: ✭ 91 (-32.59%)
Mutual labels:  webp, libwebp
image-optimizer
A free and open source tool for optimizing images and vector graphics.
Stars: ✭ 740 (+448.15%)
Mutual labels:  webp
lamba-thumbnailer
AWS S3 Video Thumbnailer with Lambda
Stars: ✭ 21 (-84.44%)
Mutual labels:  webp
webp-imageio
Java ImageIO WebP support
Stars: ✭ 135 (+0%)
Mutual labels:  webp
gfxprim
Open-source modular 2D bitmap graphics library with emphasis on speed and correctness.
Stars: ✭ 32 (-76.3%)
Mutual labels:  webp
AndroidWebP-GradlePlugin
将图片转换成WebP格式的Android构建插件,自动下载 libwebp,支持手动转换与自动转换两种模式。
Stars: ✭ 49 (-63.7%)
Mutual labels:  webp
create-optimize-images
♻️ Reusable, scalable, bash scripts to create and optimize images.
Stars: ✭ 39 (-71.11%)
Mutual labels:  webp
JayantGoel001.github.io
My Personal Portfolio.
Stars: ✭ 31 (-77.04%)
Mutual labels:  webp
v-img
📸Use webp and lazyload images
Stars: ✭ 48 (-64.44%)
Mutual labels:  webp
FroshWebP
WebP Support for Shopware
Stars: ✭ 29 (-78.52%)
Mutual labels:  webp
webpjs
📷 WebP.js Polyfill
Stars: ✭ 25 (-81.48%)
Mutual labels:  webp
togglific
Do you find web animations distracting? Togglific provides a distraction-free web experience!
Stars: ✭ 17 (-87.41%)
Mutual labels:  webp
wa-sticker-formatter
Sticker Creator for WhatsApp
Stars: ✭ 60 (-55.56%)
Mutual labels:  webp
imagecodecs
Image transformation, compression, and decompression codecs. Forked from https://pypi.org/project/imagecodecs
Stars: ✭ 56 (-58.52%)
Mutual labels:  webp
IosCodeSpecification
Ios best practices, Ios development specification, ios 开发规范,ios 最佳实践,ios编码规范
Stars: ✭ 43 (-68.15%)
Mutual labels:  webp
ipx
High performance, secure and easy to use image proxy based on Sharp and libvips.
Stars: ✭ 683 (+405.93%)
Mutual labels:  webp
webp-wasm
Webp image convertor (webassembly, works offline in browser)
Stars: ✭ 18 (-86.67%)
Mutual labels:  webp
imagor
Fast, Docker-ready image processing server in Go and libvips
Stars: ✭ 2,276 (+1585.93%)
Mutual labels:  webp
tiny
compress data for better performance
Stars: ✭ 21 (-84.44%)
Mutual labels:  webp
WhatsApp-Stickers
WhatsApp Stickers Pack For WhatsApp
Stars: ✭ 18 (-86.67%)
Mutual labels:  webp

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].