Willow
A wrapper that combines the functionality of multiple Python image libraries into one API
Install / Use
/learn @wagtail/WillowREADME
Willow image library
A wrapper that combines the functionality of multiple Python image libraries into one API.
Overview
Willow is a simple image library that combines the APIs of Pillow, Wand and OpenCV. It converts the image between the libraries when necessary.
Willow currently has basic resize and crop operations, face and feature detection and animated GIF support. New operations and library integrations can also be easily implemented.
The library is written in pure Python and supports versions 3.10, 3.11, 3.12, 3.13 and 3.14.
Examples
Resizing an image
from willow.image import Image
f = open('test.png', 'rb')
img = Image.open(f)
# Resize the image to 100x100 pixels
img = img.resize((100, 100))
# Save it
with open('test_thumbnail.png', 'wb') as out:
img.save_as_png(out)
This will open the image file with Pillow or Wand (if Pillow is unavailable).
It will then resize it to 100x100 pixels and save it back out as a PNG file.
Detecting faces
from willow.image import Image
f = open('photo.png', 'rb')
img = Image.open(f)
# Find faces
faces = img.detect_faces()
Like above, the image file will be loaded with either Pillow or Wand.
As neither Pillow nor Wand support detecting faces, Willow would automatically convert the image to OpenCV and use that to perform the detection.
Available operations
| Operation | Pillow | Wand | OpenCV |
| ------------------------------------------------ | ------ | ---- | ------ |
| get_size() | ✓ | ✓ | ✓ |
| get_frame_count() | ✓** | ✓ | ✓** |
| resize(size) | ✓ | ✓ | |
| crop(rect) | ✓ | ✓ | |
| rotate(angle) | ✓ | ✓ | |
| set_background_color_rgb(color) | ✓ | ✓ | |
| transform_colorspace_to_srgb(rendering_intent) | ✓ | | |
| auto_orient() | ✓ | ✓ | |
| save_as_jpeg(file, quality) | ✓ | ✓ | |
| save_as_png(file) | ✓ | ✓ | |
| save_as_gif(file) | ✓ | ✓ | |
| save_as_webp(file, quality) | ✓ | ✓ | |
| save_as_heic(file, quality, lossless) | ✓⁺ | | |
| save_as_avif(file, quality, lossless) | ✓ | ✓ | |
| save_as_ico(file) | ✓ | ✓ | |
| has_alpha() | ✓ | ✓ | ✓* |
| has_animation() | ✓* | ✓ | ✓* |
| get_pillow_image() | ✓ | | |
| get_wand_image() | | ✓ | |
| detect_features() | | | ✓ |
| detect_faces(cascade_filename) | | | ✓ |
* Always returns False
** Always returns 1
⁺ Requires the pillow-heif library
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
