The PIL.ImageOps Module

(New in 1.1.3) The ImageOps module contains a number of 'ready-made' image processing operations. This module is somewhat experimental, and most operators only work on L and RGB images.

Module Contents

autocontrast(image, cutoff=0, ignore=None) [#]

Maximize (normalize) image contrast. This function calculates a histogram of the input image, removes cutoff percent of the lightest and darkest pixels from the histogram, and remaps the image so that the darkest pixel becomes black (0), and the lightest becomes white (255).

image
cutoff
ignore
Returns:

colorize(image, black, white) [#]

Colorize grayscale image. The black and white arguments should be RGB tuples; this function calculates a colour wedge mapping all black pixels in the source image to the first colour, and all white pixels to the second colour.

image
black
white
Returns:

crop(image, border=0) [#]
image
border
Returns:

deform(image, deformer, resample=Image.BILINEAR) [#]
image
deformer
resample
Returns:

equalize(image, mask=None) [#]
image
mask
Returns:

expand(image, border=0, fill=0) [#]
image
border
fill
Returns:

fit(image, size, method=Image.NEAREST, bleed=0.0, centering=(0.5, 0.5)) [#]

Returns a sized and cropped version of the image, cropped to the requested aspect ratio and size.

The fit function was contributed by Kevin Cazabon.

size
method
bleed
centering
Returns:

flip(image) [#]
image
Returns:

grayscale(image) [#]
image
Returns:

invert(image) [#]
image
Returns:

mirror(image) [#]
image
Returns:

posterize(image, bits) [#]
image
bits
Returns:

solarize(image, threshold=128) [#]
image
threshold
Returns: