Skip to main content

A Python image library that sits on top of Pillow, Wand and OpenCV

Project description

Willow image library

PyPI PyPI downloads Build Status

A wrapper that combines the functionality of multiple Python image libraries into one API.

Documentation

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.8 3.9, 3.10 and 3.11.

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

Documentation

Operation Pillow Wand OpenCV
get_size()
get_frame_count() ✓** ✓**
resize(size)
crop(rect)
rotate(angle)
set_background_color_rgb(color)
auto_orient()
save_as_jpeg(file, quality)
save_as_png(file)
save_as_gif(file)
save_as_webp(file, quality)
save_as_heif(file, quality, lossless) ✓⁺
save_as_avif(file, quality, lossless) ✓⁺ ✓⁺
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

willow-1.6.2.tar.gz (112.2 kB view details)

Uploaded Source

Built Distribution

willow-1.6.2-py3-none-any.whl (118.1 kB view details)

Uploaded Python 3

File details

Details for the file willow-1.6.2.tar.gz.

File metadata

  • Download URL: willow-1.6.2.tar.gz
  • Upload date:
  • Size: 112.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for willow-1.6.2.tar.gz
Algorithm Hash digest
SHA256 e2d0450fd78ab19052d0478b888ef163e3264e8dcd1af002dd691458db98056f
MD5 f866a1183a8119bd88a211684694c239
BLAKE2b-256 3f12d9c07c0d2d4a20d9dfd325df4ce86e766658b9b00fb997f021abf175bdfa

See more details on using hashes here.

Provenance

File details

Details for the file willow-1.6.2-py3-none-any.whl.

File metadata

  • Download URL: willow-1.6.2-py3-none-any.whl
  • Upload date:
  • Size: 118.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for willow-1.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 957a4af8a7733e116a65eca34da11afe3fd52ffdb397494c8823901c25863787
MD5 959ac53867409e2de0eaa31be30cc1a8
BLAKE2b-256 ab4a6d35bd3039b432ef3d83f1a7d012abaa994ee430199849701b57df564d29

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page