variations


Namevariations JSON
Version 0.3.3 PyPI version JSON
download
home_pagehttps://github.com/dldevinc/variations
SummaryA simple interface that allows processing of images.
upload_time2023-04-25 07:36:59
maintainerMihail Mishakin
docs_urlNone
authorMihail Mishakin
requires_python>=3.7
licenseBSD license
keywords
VCS
bugtrack_url
requirements pytest pytest-cov pytest-xdist
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # variations

A simple interface that allows processing of images.

[![PyPI](https://img.shields.io/pypi/v/variations.svg)](https://pypi.org/project/variations/)
[![Build Status](https://github.com/dldevinc/variations/actions/workflows/tests.yml/badge.svg)](https://github.com/dldevinc/variations)
[![Software license](https://img.shields.io/pypi/l/variations.svg)](https://pypi.org/project/variations/)

## Compatibility

-   `python` >= 3.7

## Installation

1. Run `pip install variations`

2. (**optional**) If you want to use [StackBlur](https://github.com/dldevinc/pillow-stackblur)

    `pip install pillow-stackblur`

3. (**optional**) If you want to use [Face Detection](https://github.com/ageitgey/face_recognition)

    `pip install face_recognition`

## Usage

```python
from PIL import Image
from variations import processors
from variations.variation import Variation
from variations.utils import prepare_image

variation = Variation(
    size=(400, 0),
    max_height=800,
    clip=False,
    upscale=False,
    anchor=processors.Anchor.TOP_LEFT,
    jpeg=dict(
        quality=92,
    ),
    webp=dict(
        lossless=True,
        quality=90,
    ),
    postprocessors=[
        processors.ColorOverlay('#FF0000', overlay_opacity=0.25),
    ],
)

img = Image.open('source.jpg')
img = prepare_image(img, draft_size=variation.get_output_size(img.size))
new_img = variation.process(img)
dest_path = variation.replace_extension('dest.jpg')
variation.save(new_img, dest_path)
```

## Options

|                    | Type                 | Examples                                                        | Description                                                                                                                                            |
| ------------------ | -------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **size**           | tuple<br>list        | `(640, 480)`<br>`(640, 0)`                                      | The **canvas** size of image. If you set the width or height to zero, the corresponding value will be automatically adjusted based on the aspect ratio |
| **max_width**      | int                  | `640`                                                           | It specifies the maximum width in pixels.This option have meaning only when corresponding value in `size` is zero                                      |
| **max_height**     | int                  | `480`                                                           | It specifies the maximum height in pixels.This option have meaning only when corresponding value in `size` is zero                                     |
| **clip**           | bool                 |                                                                 | When set to `True`, the image can be cropped when filling the canvas.                                                                                  |
| **upscale**        | bool                 |                                                                 | When set to `True`, the image can be upscaled when filling the canvas.                                                                                 |
| **anchor**         | str<br>tuple<br>list | `'tr'` (top right)<br>`'c'` (center)<br>`(1, 1)` (bottom right) | Defines the anchor point.                                                                                                                              |
| **face_detection** | bool                 |                                                                 | Use a face detection system to find anchor point. You must install [facial recognition api](https://github.com/ageitgey/face_recognition) to use this. |
| **format**         | str                  | `'JPEG'` `'png'` `'WebP'`                                       | Enforce output image format. Defaults to `'AUTO'`, which means keep input format.                                                                      |
| **preprocessors**  | list                 | `[processors.Crop(width=200, height=120, x=50, y=50)]`          | [PilKit](https://github.com/matthewwithanm/pilkit) processors are invoked before the main processing stage                                             |
| **postprocessors** | list                 | `[processors.ColorOverlay('#0000FF', 0.10)]`                    | [PilKit](https://github.com/matthewwithanm/pilkit) processors are invoked after the main processing stage                                              |

## Additional options for specific formats

It is possible to pass additional [options](https://pillow.readthedocs.io/en/latest/handbook/image-file-formats.html)
to `Image.save()` method.

```python
Variation(
    # ...
    jpeg=dict(
        quality=80,
        progressive=True,
    ),
    webp=dict(
        autoconvert=False,
        quality=80,
    ),
    tiff=dict(
        compression='tiff_jpeg',
    )
)
```

## Development and Testing

After cloning the Git repository, you should install this
in a virtualenv and set up for development:

```shell script
virtualenv .venv
source .venv/bin/activate
pip install -r ./requirements.txt
pre-commit install
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/dldevinc/variations",
    "name": "variations",
    "maintainer": "Mihail Mishakin",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "x896321475@gmail.com",
    "keywords": "",
    "author": "Mihail Mishakin",
    "author_email": "x896321475@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/10/746e6cfccff1fa2a29140bb071f34241321d4800e733e909a0c4285f9400/variations-0.3.3.tar.gz",
    "platform": "OS Independent",
    "description": "# variations\n\nA simple interface that allows processing of images.\n\n[![PyPI](https://img.shields.io/pypi/v/variations.svg)](https://pypi.org/project/variations/)\n[![Build Status](https://github.com/dldevinc/variations/actions/workflows/tests.yml/badge.svg)](https://github.com/dldevinc/variations)\n[![Software license](https://img.shields.io/pypi/l/variations.svg)](https://pypi.org/project/variations/)\n\n## Compatibility\n\n-   `python` >= 3.7\n\n## Installation\n\n1. Run `pip install variations`\n\n2. (**optional**) If you want to use [StackBlur](https://github.com/dldevinc/pillow-stackblur)\n\n    `pip install pillow-stackblur`\n\n3. (**optional**) If you want to use [Face Detection](https://github.com/ageitgey/face_recognition)\n\n    `pip install face_recognition`\n\n## Usage\n\n```python\nfrom PIL import Image\nfrom variations import processors\nfrom variations.variation import Variation\nfrom variations.utils import prepare_image\n\nvariation = Variation(\n    size=(400, 0),\n    max_height=800,\n    clip=False,\n    upscale=False,\n    anchor=processors.Anchor.TOP_LEFT,\n    jpeg=dict(\n        quality=92,\n    ),\n    webp=dict(\n        lossless=True,\n        quality=90,\n    ),\n    postprocessors=[\n        processors.ColorOverlay('#FF0000', overlay_opacity=0.25),\n    ],\n)\n\nimg = Image.open('source.jpg')\nimg = prepare_image(img, draft_size=variation.get_output_size(img.size))\nnew_img = variation.process(img)\ndest_path = variation.replace_extension('dest.jpg')\nvariation.save(new_img, dest_path)\n```\n\n## Options\n\n|                    | Type                 | Examples                                                        | Description                                                                                                                                            |\n| ------------------ | -------------------- | --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |\n| **size**           | tuple<br>list        | `(640, 480)`<br>`(640, 0)`                                      | The **canvas** size of image. If you set the width or height to zero, the corresponding value will be automatically adjusted based on the aspect ratio |\n| **max_width**      | int                  | `640`                                                           | It specifies the maximum width in pixels.This option have meaning only when corresponding value in `size` is zero                                      |\n| **max_height**     | int                  | `480`                                                           | It specifies the maximum height in pixels.This option have meaning only when corresponding value in `size` is zero                                     |\n| **clip**           | bool                 |                                                                 | When set to `True`, the image can be cropped when filling the canvas.                                                                                  |\n| **upscale**        | bool                 |                                                                 | When set to `True`, the image can be upscaled when filling the canvas.                                                                                 |\n| **anchor**         | str<br>tuple<br>list | `'tr'` (top right)<br>`'c'` (center)<br>`(1, 1)` (bottom right) | Defines the anchor point.                                                                                                                              |\n| **face_detection** | bool                 |                                                                 | Use a face detection system to find anchor point. You must install [facial recognition api](https://github.com/ageitgey/face_recognition) to use this. |\n| **format**         | str                  | `'JPEG'` `'png'` `'WebP'`                                       | Enforce output image format. Defaults to `'AUTO'`, which means keep input format.                                                                      |\n| **preprocessors**  | list                 | `[processors.Crop(width=200, height=120, x=50, y=50)]`          | [PilKit](https://github.com/matthewwithanm/pilkit) processors are invoked before the main processing stage                                             |\n| **postprocessors** | list                 | `[processors.ColorOverlay('#0000FF', 0.10)]`                    | [PilKit](https://github.com/matthewwithanm/pilkit) processors are invoked after the main processing stage                                              |\n\n## Additional options for specific formats\n\nIt is possible to pass additional [options](https://pillow.readthedocs.io/en/latest/handbook/image-file-formats.html)\nto `Image.save()` method.\n\n```python\nVariation(\n    # ...\n    jpeg=dict(\n        quality=80,\n        progressive=True,\n    ),\n    webp=dict(\n        autoconvert=False,\n        quality=80,\n    ),\n    tiff=dict(\n        compression='tiff_jpeg',\n    )\n)\n```\n\n## Development and Testing\n\nAfter cloning the Git repository, you should install this\nin a virtualenv and set up for development:\n\n```shell script\nvirtualenv .venv\nsource .venv/bin/activate\npip install -r ./requirements.txt\npre-commit install\n```\n",
    "bugtrack_url": null,
    "license": "BSD license",
    "summary": "A simple interface that allows processing of images.",
    "version": "0.3.3",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f99743d7d5ce691dd8194285f973529eeddd4659a8e581f6a432068b481910f0",
                "md5": "2410e85203e919e004bd87a56a95e4b7",
                "sha256": "b30b10e979bc232060953cf17efd8f9af11f7efae4523b81bfb1b77a7bc52697"
            },
            "downloads": -1,
            "filename": "variations-0.3.3-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2410e85203e919e004bd87a56a95e4b7",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 15718,
            "upload_time": "2023-04-25T07:36:57",
            "upload_time_iso_8601": "2023-04-25T07:36:57.697115Z",
            "url": "https://files.pythonhosted.org/packages/f9/97/43d7d5ce691dd8194285f973529eeddd4659a8e581f6a432068b481910f0/variations-0.3.3-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c10746e6cfccff1fa2a29140bb071f34241321d4800e733e909a0c4285f9400",
                "md5": "52237bb4966e1eed5581ded1bf62ebbf",
                "sha256": "0d5e0abf74b1ffca27afdbdf3595f9cb0b6bc0c70616c83d4a3235830d05af80"
            },
            "downloads": -1,
            "filename": "variations-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "52237bb4966e1eed5581ded1bf62ebbf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 19388,
            "upload_time": "2023-04-25T07:36:59",
            "upload_time_iso_8601": "2023-04-25T07:36:59.466073Z",
            "url": "https://files.pythonhosted.org/packages/6c/10/746e6cfccff1fa2a29140bb071f34241321d4800e733e909a0c4285f9400/variations-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-25 07:36:59",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "dldevinc",
    "github_project": "variations",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "7.3.1"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "==",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "pytest-xdist",
            "specs": [
                [
                    "==",
                    "3.2.1"
                ]
            ]
        }
    ],
    "tox": true,
    "lcname": "variations"
}
        
Elapsed time: 0.07292s