Willow


NameWillow JSON
Version 1.9.0 PyPI version JSON
download
home_pageNone
SummaryA Python image library that sits on top of Pillow, Wand and OpenCV
upload_time2024-10-26 22:06:01
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords imaging
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [Willow image library](https://pypi.org/project/Willow/)

[![PyPI](https://img.shields.io/pypi/v/Willow.svg)](https://pypi.org/project/Willow/)
[![PyPI downloads](https://img.shields.io/pypi/dm/Willow.svg)](https://pypi.org/project/Willow/)
[![Build Status](https://github.com/torchbox/Willow/workflows/CI/badge.svg)](https://github.com/wagtail/Willow/actions)

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

[Documentation](https://willow.wagtail.org)

## Overview

Willow is a simple image library that combines the APIs of [Pillow](https://pillow.readthedocs.io/), [Wand](https://docs.wand-py.org) and [OpenCV](https://opencv.org/).
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](https://willow.wagtail.org/latest/guide/extend.html).

The library is written in pure Python and supports versions 3.9, 3.10, 3.11, 3.12, and 3.13.

## Examples

### Resizing an image

```python
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

```python
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](https://willow.wagtail.org/latest/guide/operations.html)

| 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](https://pypi.org/project/pillow-heif/) library


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "Willow",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Wagtail Core team <hello@wagtail.org>",
    "keywords": "Imaging",
    "author": null,
    "author_email": "Karl Hobley <karl@kaed.uk>",
    "download_url": "https://files.pythonhosted.org/packages/2b/07/7937bb91ba3373133d903ec6c8a7a3fe0bec6ac964c7f2e532188e230c9b/willow-1.9.0.tar.gz",
    "platform": null,
    "description": "# [Willow image library](https://pypi.org/project/Willow/)\n\n[![PyPI](https://img.shields.io/pypi/v/Willow.svg)](https://pypi.org/project/Willow/)\n[![PyPI downloads](https://img.shields.io/pypi/dm/Willow.svg)](https://pypi.org/project/Willow/)\n[![Build Status](https://github.com/torchbox/Willow/workflows/CI/badge.svg)](https://github.com/wagtail/Willow/actions)\n\nA wrapper that combines the functionality of multiple Python image libraries into one API.\n\n[Documentation](https://willow.wagtail.org)\n\n## Overview\n\nWillow is a simple image library that combines the APIs of [Pillow](https://pillow.readthedocs.io/), [Wand](https://docs.wand-py.org) and [OpenCV](https://opencv.org/).\nIt converts the image between the libraries when necessary.\n\nWillow currently has basic resize and crop operations, face and feature detection and animated GIF support.\nNew operations and library integrations can also be [easily implemented](https://willow.wagtail.org/latest/guide/extend.html).\n\nThe library is written in pure Python and supports versions 3.9, 3.10, 3.11, 3.12, and 3.13.\n\n## Examples\n\n### Resizing an image\n\n```python\nfrom willow.image import Image\n\nf = open('test.png', 'rb')\nimg = Image.open(f)\n\n# Resize the image to 100x100 pixels\nimg = img.resize((100, 100))\n\n# Save it\nwith open('test_thumbnail.png', 'wb') as out:\n   img.save_as_png(out)\n```\n\nThis will open the image file with Pillow or Wand (if Pillow is unavailable).\n\nIt will then resize it to 100x100 pixels and save it back out as a PNG file.\n\n### Detecting faces\n\n```python\nfrom willow.image import Image\n\nf = open('photo.png', 'rb')\nimg = Image.open(f)\n\n# Find faces\nfaces = img.detect_faces()\n```\n\nLike above, the image file will be loaded with either Pillow or Wand.\n\nAs neither Pillow nor Wand support detecting faces, Willow would automatically convert the image to OpenCV and use that to perform the detection.\n\n## Available operations\n\n[Documentation](https://willow.wagtail.org/latest/guide/operations.html)\n\n| Operation                                        | Pillow | Wand | OpenCV |\n| ------------------------------------------------ | ------ | ---- | ------ |\n| `get_size()`                                     | \u2713      | \u2713    | \u2713      |\n| `get_frame_count()`                              | \u2713\\*\\*  | \u2713    | \u2713\\*\\*  |\n| `resize(size)`                                   | \u2713      | \u2713    |        |\n| `crop(rect)`                                     | \u2713      | \u2713    |        |\n| `rotate(angle)`                                  | \u2713      | \u2713    |        |\n| `set_background_color_rgb(color)`                | \u2713      | \u2713    |        |\n| `transform_colorspace_to_srgb(rendering_intent)` | \u2713      |      |        |\n| `auto_orient()`                                  | \u2713      | \u2713    |        |\n| `save_as_jpeg(file, quality)`                    | \u2713      | \u2713    |        |\n| `save_as_png(file)`                              | \u2713      | \u2713    |        |\n| `save_as_gif(file)`                              | \u2713      | \u2713    |        |\n| `save_as_webp(file, quality)`                    | \u2713      | \u2713    |        |\n| `save_as_heic(file, quality, lossless)`          | \u2713\u207a     |      |        |\n| `save_as_avif(file, quality, lossless)`          | \u2713\u207a     | \u2713\u207a   |        |\n| `save_as_ico(file)`                              | \u2713      | \u2713    |        |\n| `has_alpha()`                                    | \u2713      | \u2713    | \u2713\\*    |\n| `has_animation()`                                | \u2713\\*    | \u2713    | \u2713\\*    |\n| `get_pillow_image()`                             | \u2713      |      |        |\n| `get_wand_image()`                               |        | \u2713    |        |\n| `detect_features()`                              |        |      | \u2713      |\n| `detect_faces(cascade_filename)`                 |        |      | \u2713      |\n\n\\* Always returns `False`\n\n\\*\\* Always returns `1`\n\n\u207a Requires the [pillow-heif](https://pypi.org/project/pillow-heif/) library\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python image library that sits on top of Pillow, Wand and OpenCV",
    "version": "1.9.0",
    "project_urls": {
        "Changelog": "https://github.com/wagtail/Willow/blob/main/CHANGELOG.txt",
        "Documentation": "https://willow.wagtail.org/",
        "Source": "https://github.com/wagtail/Willow"
    },
    "split_keywords": [
        "imaging"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ddc010a11f2dc0dc485a397bd3f66098805b6e39e7317f5acb72b415d1d7a559",
                "md5": "1cace71ee1c1e42ca2f448e933d64ed0",
                "sha256": "11a13097cffe501898cd434bb5761fb6cdbdb774a7853094cb56a4ba57cbbff7"
            },
            "downloads": -1,
            "filename": "willow-1.9.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1cace71ee1c1e42ca2f448e933d64ed0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 119156,
            "upload_time": "2024-10-26T22:05:59",
            "upload_time_iso_8601": "2024-10-26T22:05:59.971961Z",
            "url": "https://files.pythonhosted.org/packages/dd/c0/10a11f2dc0dc485a397bd3f66098805b6e39e7317f5acb72b415d1d7a559/willow-1.9.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2b077937bb91ba3373133d903ec6c8a7a3fe0bec6ac964c7f2e532188e230c9b",
                "md5": "1f1b106c669921c52efd7a8e70dc6891",
                "sha256": "ffac1406275ae30b60e7c6cbd1245f0bc359d1b5731002b18a712aaf424a5102"
            },
            "downloads": -1,
            "filename": "willow-1.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1f1b106c669921c52efd7a8e70dc6891",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 113373,
            "upload_time": "2024-10-26T22:06:01",
            "upload_time_iso_8601": "2024-10-26T22:06:01.662200Z",
            "url": "https://files.pythonhosted.org/packages/2b/07/7937bb91ba3373133d903ec6c8a7a3fe0bec6ac964c7f2e532188e230c9b/willow-1.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-26 22:06:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wagtail",
    "github_project": "Willow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "willow"
}
        
Elapsed time: 0.34497s