Skip to main content

A simple interface that allows to process images.

Project description

variations

A simple interface that allows processing images.

Compatibility

  • python >= 3.4

Installation

  1. Run pip install variations

  2. (optional) If you want to use StackBlur

    pip install pillow-stackblur

3 (optional) If you want to use Face Detection

``pip install face_recognition``

Usage

    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
list
(640, 480)
(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 maximim width in pixels.This option have meaning only when corresponding value in size is zero
max_height int 480 It specifies the maximim 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
tuple
list
'tr' (top right)
'c' (center)
(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 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 processors are invoked before the main processing stage
postprocessors list [processors.ColorOverlay('#0000FF', 0.10)] PilKit processors are invoked after the main processing stage

Additional options for specific formats

It is possible to pass additional options to Image.save() method.

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

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

variations-0.0.13.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

variations-0.0.13-py2.py3-none-any.whl (15.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file variations-0.0.13.tar.gz.

File metadata

  • Download URL: variations-0.0.13.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for variations-0.0.13.tar.gz
Algorithm Hash digest
SHA256 4f2b2dc96b4ade7da220b0a06812ca9bc742413fc4a38c985db919457e82c959
MD5 499c9cb625040dfb8831373d43510623
BLAKE2b-256 4dfd3f8d9b7dcf1ac2347a52d4205b63d91cedf2b076f265cb686c2d4b3ec801

See more details on using hashes here.

File details

Details for the file variations-0.0.13-py2.py3-none-any.whl.

File metadata

  • Download URL: variations-0.0.13-py2.py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.3

File hashes

Hashes for variations-0.0.13-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 3c4cc67ebe79ebfd9cca29cc54a4949b6b33e2991e785397acdec373c30d7bb0
MD5 f944cd9673bf4203c2162e039984b81c
BLAKE2b-256 f87edfbb143d239bd3238415943690637a24de7184b33d19eadb3be8206c9875

See more details on using hashes here.

Supported by

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