Willow


NameWillow JSON
Version 1.7.0 PyPI version JSON
download
home_pageNone
SummaryA Python image library that sits on top of Pillow, Wand and OpenCV
upload_time2023-11-27 10:45:56
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
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.readthedocs.io/en/latest/index.html)

## 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.readthedocs.org/en/latest/guide/extend.html).

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

## 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.readthedocs.org/en/latest/reference.html#builtin-operations)

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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "Willow",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "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/3c/04/82b21e557c5d6e33ff8969be61cf62766e2c7a9312a1ea580ee017d445b4/willow-1.7.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.readthedocs.io/en/latest/index.html)\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.readthedocs.org/en/latest/guide/extend.html).\n\nThe library is written in pure Python and supports versions 3.8 3.9, 3.10, 3.11 and 3.12.\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\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.readthedocs.org/en/latest/reference.html#builtin-operations)\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| `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_heif(file, quality, lossless)` | \u2713\u207a     |      |        |\n| `save_as_avif(file, quality, lossless)` | \u2713\u207a     | \u2713\u207a   |        |\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",
    "bugtrack_url": null,
    "license": null,
    "summary": "A Python image library that sits on top of Pillow, Wand and OpenCV",
    "version": "1.7.0",
    "project_urls": {
        "Changelog": "https://github.com/wagtail/Willow/blob/main/CHANGELOG.txt",
        "Source": "https://github.com/wagtail/Willow"
    },
    "split_keywords": [
        "imaging"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ac26142cdd526d29ed7e9d106f5af12d3254fdaf5dcbff5f9b1a1f49656cda27",
                "md5": "d8fba2fed637d6d3c5ddf066d4499035",
                "sha256": "c7cb6804a58df670c6ea6d8de21210e9c2f5aba0d91929763fa6e13e94e550cd"
            },
            "downloads": -1,
            "filename": "willow-1.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d8fba2fed637d6d3c5ddf066d4499035",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 118096,
            "upload_time": "2023-11-27T10:45:53",
            "upload_time_iso_8601": "2023-11-27T10:45:53.648456Z",
            "url": "https://files.pythonhosted.org/packages/ac/26/142cdd526d29ed7e9d106f5af12d3254fdaf5dcbff5f9b1a1f49656cda27/willow-1.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3c0482b21e557c5d6e33ff8969be61cf62766e2c7a9312a1ea580ee017d445b4",
                "md5": "355ac3eb9f6833fee168218b3375abc8",
                "sha256": "2202ac8852d24312b4d71a4ef9f75f813c8799d440f58e905f055ea4a220c1b1"
            },
            "downloads": -1,
            "filename": "willow-1.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "355ac3eb9f6833fee168218b3375abc8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 112367,
            "upload_time": "2023-11-27T10:45:56",
            "upload_time_iso_8601": "2023-11-27T10:45:56.723076Z",
            "url": "https://files.pythonhosted.org/packages/3c/04/82b21e557c5d6e33ff8969be61cf62766e2c7a9312a1ea580ee017d445b4/willow-1.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-27 10:45:56",
    "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.15142s