Registry / data / willow

willow

JSON →
library1.12.0pypypi✓ verified 25d ago

Willow is a Python image library that provides a unified API over multiple backend imaging libraries such as Pillow, Wand (ImageMagick), and OpenCV. It offers common image manipulation capabilities like resizing, cropping, and format conversion, allowing developers to switch backends with minimal code changes. The current version is 1.12.0, and it maintains a regular release cadence, often aligning with new Python and backend library versions.

pip install willow
INSTALL
IMPORT
SIG · WILLOW
W
willow
datapythonv1.12.0
Install
1.9s avg
Import
222ms
Disk
37MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.229s · 38.9MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.9s · import 0.215s · 40MB
37MB installed
● package 37MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Image
from willow.image import Image
The primary interface for loading and manipulating images, which delegates to an appropriate backend.
get_image_backend
from willow.image import get_image_backend
Utility to explicitly get the currently active image backend.
PillowImage
from willow.plugins.pillow import PillowImage
Direct import for the Pillow-specific image class, useful when you want to force a specific backend.

This quickstart demonstrates how to load, resize, and save an image using Willow. It automatically detects the best available backend (like Pillow) and performs common image manipulations. Ensure you have installed Willow with at least one backend (e.g., `pip install 'willow[Pillow]'`) for this code to run successfully.

import os from willow.image import Image # Create dummy image data for demonstration # In a real application, you'd load from a file or network stream dummy_image_data = b'GIF89a\x01\x00\x01\x00\x00\xff\x00,\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x00;' # Minimal valid GIF try: # Load the image using Willow's automatic backend detection # Requires a backend like Pillow to be installed (e.g., pip install 'willow[Pillow]') image = Image.check(dummy_image_data) # Get original image properties print(f"Original format: {image.format}") print(f"Original size: {image.get_size()}") # Resize the image image.resize((50, 50)) # Get new image properties print(f"Resized size: {image.get_size()}") # Save the processed image data (e.g., as JPEG) processed_data = image.save_as_jpeg() # Optionally, save to a file output_filename = 'processed_image.jpg' with open(output_filename, 'wb') as f: f.write(processed_data) print(f"Image saved to {output_filename}") # Clean up dummy file os.remove(output_filename) except Exception as e: print(f"Error processing image: {e}") print("Please ensure a backend like Pillow is installed (e.g., pip install 'willow[Pillow]').")
Debug
Known issues
breakingWillow v1.12.0 and later have dropped support for Python 3.9. Users on Python 3.9 must upgrade their Python environment to 3.10 or newer to use the latest Willow versions.
fix
Upgrade Python to 3.10 or a later supported version. For example, `python3.10 -m pip install willow`.
affects: >=1.12.0
breakingWillow v1.11.0 raised the minimum required Pillow version to 11.3.0. Further, v1.12.0 added support for Pillow 12+. Using older Pillow versions (below 11.3.0) with recent Willow releases will lead to compatibility issues, especially with newer image formats like AVIF.
fix
Ensure Pillow is updated to version 11.3.0 or higher. For example, `pip install --upgrade 'willow[Pillow]'`.
affects: >=1.11.0
gotchaStarting with Willow v1.8.0, CMYK images with an ICC profile are automatically converted to sRGB before encoding (e.g., to PNG, WebP, AVIF, HEIC). This is done to ensure accurate color representation, as Pillow's default CMYK to RGB conversion historically ignored profiles. This change might result in slightly different color appearances for such images compared to versions prior to v1.8.0.
fix
Be aware of this automatic color space conversion when processing CMYK images. If you require custom CMYK handling, you may need to preprocess images before passing them to Willow.
affects: >=1.8.0
gotchaA plain `pip install willow` only installs the core library without any backend. To get functional image processing capabilities, you must install Willow with at least one optional backend dependency, such as Pillow, Wand, or OpenCV.
fix
Install Willow with the desired backend using the bracket syntax, e.g., `pip install 'willow[Pillow]'` for the Pillow backend, which is generally recommended for most use cases.
affects: All versions
gotchaFor HEIC/HEIF image format support when using the Pillow backend, the `pillow_heif` library is required. This library is not included with `willow[Pillow]` by default and must be installed separately.
fix
Install `pillow_heif` in addition to Willow: `pip install 'willow[Pillow]' pillow_heif`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'willow'
The `willow` library has not been installed in the current Python environment.
fix
pip install willow
willow.exceptions.WillowException: No suitable backend found for operation
The `willow` library requires at least one supported backend imaging library (such as Pillow, Wand, or OpenCV) to be installed to perform image operations, and none were found or detected.
fix
pip install willow[pillow] # or willow[wand] or willow[opencv] depending on your preferred backend
willow.exceptions.BadImageOperationError: Cannot identify image file
The provided file-like object or path does not contain a recognizable image format, or the image data is corrupted.
fix
Ensure the input file is a valid and supported image format (e.g., JPEG, PNG, GIF) and that the file is not corrupted.
AttributeError: 'Image' object has no attribute 'save_as_jpg'
The `willow.image.Image` object does not have a method named `save_as_jpg`; the correct method for saving as JPEG is `save_as_jpeg`.
fix
image.save_as_jpeg(output_file_object)
ImportError: libMagickWand-6.Q16.so: cannot open shared object file: No such file or directory
The `wand` backend, if chosen by `willow`, cannot find the underlying ImageMagick shared library files required for its operation on the system.
fix
Install ImageMagick and its development files on your operating system (e.g., `sudo apt-get install imagemagick libmagickwand-dev` on Debian/Ubuntu, or `brew install imagemagick` on macOS).
Upgrade
Version history
1.12.0latest on PyPI · released Oct 26, 2025
Audit
Dependencies
PillowoptionalMost common image processing backend.
WandoptionalImageMagick wrapper backend.
opencv-pythonoptionalOpenCV backend.
pillow_heifoptionalRequired for HEIC/HEIF support with the Pillow backend.
Agent activity
39 hits · last 30 days
node
32
OpenAI (training)
1
Resources
willow — pip install willow · libregistry