All Projects → anibali → Pywebp

anibali / Pywebp

Licence: mit
Python bindings for WebP

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Pywebp

Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (+3882.86%)
Mutual labels:  webp, image
Vulcan
Multi image downloader with priority in Swift
Stars: ✭ 291 (+731.43%)
Mutual labels:  webp, image
Lilliput
Resize images and animated GIFs in Go
Stars: ✭ 1,690 (+4728.57%)
Mutual labels:  webp, image
Quick Picture Viewer
🖼️ Lightweight, versatile desktop image viewer for Windows. The best replacement for the default Windows photo viewer.
Stars: ✭ 237 (+577.14%)
Mutual labels:  webp, image
Sdwebimage
Asynchronous image downloader with cache support as a UIImageView category
Stars: ✭ 23,928 (+68265.71%)
Mutual labels:  webp, image
Tiny Site
图片优化
Stars: ✭ 65 (+85.71%)
Mutual labels:  webp, image
Webp
WebP decoder and encoder for Go (Zero Dependencies).
Stars: ✭ 270 (+671.43%)
Mutual labels:  webp, image
Pillow
The friendly PIL fork (Python Imaging Library)
Stars: ✭ 9,241 (+26302.86%)
Mutual labels:  image, pillow
Pinremoteimage
A thread safe, performant, feature rich image fetcher
Stars: ✭ 3,929 (+11125.71%)
Mutual labels:  webp, image
Sharp
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
Stars: ✭ 21,131 (+60274.29%)
Mutual labels:  webp, image
Imaginary
Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing
Stars: ✭ 4,107 (+11634.29%)
Mutual labels:  webp, image
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (+2077.14%)
Mutual labels:  webp, image
Nuxt Optimized Images
🌅🚀 Automatically optimizes images used in Nuxt.js projects (JPEG, PNG, SVG, WebP and GIF).
Stars: ✭ 717 (+1948.57%)
Mutual labels:  webp, image
Pixterm
Draw images in your ANSI terminal with true color
Stars: ✭ 782 (+2134.29%)
Mutual labels:  webp, image
Ambient
Lightweight ambient light javascript library for HTML image and video elements
Stars: ✭ 20 (-42.86%)
Mutual labels:  image
Ruby Gem Downloads Badge
Clean and simple gem downloads count badge, courtesy of http://shields.io/. You can checkout the application directly at the following URL:
Stars: ✭ 29 (-17.14%)
Mutual labels:  image
Detection Of Breast Cancer Using Neural Networks
This project is made in Matlab Platform and it detects whether a person has cancer or not by taking into account his/her mammogram.
Stars: ✭ 15 (-57.14%)
Mutual labels:  image
Upload Image To Smms By Automator
Drag your image to me, I will upload it to SM.MS automatically and backup info to iCloud. 只需拖拽图片即可轻松上传至 SM.MS 图床并且复制链接,所有图片和链接信息会被备份至 iCloud 方便后期检索。
Stars: ✭ 15 (-57.14%)
Mutual labels:  image
Rverify.js
✅❎ A lightweight image rotation verification plugin.
Stars: ✭ 33 (-5.71%)
Mutual labels:  image
Smartcircle
✂️Automatically determine where to crop a circular image out of a rectangular.
Stars: ✭ 29 (-17.14%)
Mutual labels:  image

WebP Python bindings

CircleCI license PyPI GitHub

Installation

pip install webp

Requirements

  • libwebp (tested with v1.0.3)
    • Install libwebpmux and libwebpdemux components as well.
    • Check out the Dockerfile for steps to build from source on Ubuntu.
  • Python 3 (tested with v3.6)
  • cffi
  • Pillow
  • numpy

Usage

import webp

Simple API

# Save an image
webp.save_image(img, 'image.webp', quality=80)

# Load an image
img = webp.load_image('image.webp', 'RGBA')

# Save an animation
webp.save_images(imgs, 'anim.webp', fps=10, lossless=True)

# Load an animation
imgs = webp.load_images('anim.webp', 'RGB', fps=10)

If you prefer working with numpy arrays, use the functions imwrite, imread, mimwrite, and mimread instead.

Advanced API

# Encode a PIL image to WebP in memory, with encoder hints
pic = webp.WebPPicture.from_pil(img)
config = WebPConfig.new(preset=webp.WebPPreset.PHOTO, quality=70)
buf = pic.encode(config).buffer()

# Read a WebP file and decode to a BGR numpy array
with open('image.webp', 'rb') as f:
  webp_data = webp.WebPData.from_buffer(f.read())
  arr = webp_data.decode(color_mode=WebPColorMode.BGR)

# Save an animation
enc = webp.WebPAnimEncoder.new(width, height)
timestamp_ms = 0
for img in imgs:
  pic = webp.WebPPicture.from_pil(img)
  enc.encode_frame(pic, timestamp_ms)
  timestamp_ms += 250
anim_data = enc.assemble(timestamp_ms)
with open('anim.webp', 'wb') as f:
  f.write(anim_data.buffer())

# Load an animation
with open('anim.webp', 'rb') as f:
  webp_data = webp.WebPData.from_buffer(f.read())
  dec = webp.WebPAnimDecoder.new(webp_data)
  for arr, timestamp_ms in dec.frames():
    # `arr` contains decoded pixels for the frame
    # `timestamp_ms` contains the _end_ time of the frame
    pass

Features

  • Picture encoding/decoding
  • Animation encoding/decoding
  • Automatic memory management
  • Simple API for working with PIL.Image objects

Not implemented

  • Encoding/decoding still images in YUV color mode
  • Advanced muxing/demuxing (color profiles, etc.)
  • Expose all useful fields

Developer notes

Running tests

The CircleCI local CLI should be used to run tests in an isolated environment:

$ circleci local execute

Known issues

  • An animation where all frames are identical will "collapse" in on itself, resulting in a single frame. Unfortunately, WebP seems to discard timestamp information in this case, which breaks webp.load_images when the FPS is specified.
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].