A simple interface that allows to process images.
Project description
variations
A simple interface that allows to process images.
Compatibility
python
>= 3.4
Installation
-
Install Pillow
pip install Pillow
-
Install pilkit
pip install pilkit
-
Run
pip install variations
-
(optional) If you want to use StackBlur
pip install pillow-stackblur
-
(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) (0, 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' 'WebM' |
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 |
Project details
Release history Release notifications | RSS feed
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.9.tar.gz
(12.9 kB
view hashes)
Built Distribution
variations-0.0.9-py3-none-any.whl
(15.0 kB
view hashes)
Close
Hashes for variations-0.0.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc4f4fccc3d12d549e290d5afb418689aab1e2a68f8fb6dce0e6c9c635441b41 |
|
MD5 | c04b52ee805fe9f71e39672399ed8f48 |
|
BLAKE2b-256 | af7feea86601f333ab9500588e1d197f1671de312a08943030cdb727cf4d88b0 |