The `webp` library provides Python bindings for `libwebp`, enabling encoding, decoding, reading, and saving of WebP images. It integrates seamlessly with Pillow (PIL) for image manipulation, making it easy to convert between various image formats and WebP. The library is actively maintained with regular updates, typically bundling the latest `libwebp` version to ensure security and performance. Current version is 0.4.0.
pip install webpVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to create a simple Pillow image, encode it into WebP format bytes, and then decode those bytes back into a Pillow image using the `webp` library's `imencode` and `imdecode` functions.
Ensure `passes` is set to a value like `2` or higher when using `target_size`: `webp.imencode(img, target_size=100_000, passes=2)`.
Upgrade to `webp>=0.3.0` immediately to patch the `libwebp` vulnerability: `pip install --upgrade webp`.
Always use the public API functions directly from the `webp` package (e.g., `from webp import imencode, imdecode, imread, imsave`).
No dependency data recorded yet.