1
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
4
<meta http-equiv='Content-Type' content='text/html; charset=us-ascii' />
5
<title>The PIL.ImageChops Module</title>
6
<link rel='stylesheet' href='effbot.css' type='text/css' />
9
<h1>The PIL.ImageChops Module</h1>
10
<p>The <b>ImageChops</b> module contains a number of arithmetical image
11
operations, called <i>channel operations</i> ("chops"). These can be
12
used for various purposes, including special effects, image
13
compositions, algorithmic painting, and more.
15
At this time, channel operations are only implemented for 8-bit
16
images (e.g. "L" and "RGB").
18
Most channel operations take one or two image arguments and returns
19
a new image. Unless otherwise noted, the result of a channel
20
operation is always clipped to the range 0 to MAX (which is 255 for
21
all modes supported by the operations in this module).
22
</p><h2>Module Contents</h2>
24
<dt><a id='PIL.ImageChops.add-function' name='PIL.ImageChops.add-function'><b>add(image1, image2, scale=1.0, offset=0)</b></a> [<a href='#PIL.ImageChops.add-function'>#</a>]</dt>
27
((image1 + image2) / scale + offset).
29
Adds two images, dividing the result by scale and adding the
30
offset. If omitted, scale defaults to 1.0, and offset to 0.0.
33
<dt><i>image1</i></dt>
36
<dt><i>image1</i></dt>
44
<dt><a id='PIL.ImageChops.add_modulo-function' name='PIL.ImageChops.add_modulo-function'><b>add_modulo(image1, image2)</b></a> [<a href='#PIL.ImageChops.add_modulo-function'>#</a>]</dt>
46
<p>Add images without clipping
47
((image1 + image2) % MAX).
49
Adds two images, without clipping the result.
52
<dt><i>image1</i></dt>
55
<dt><i>image1</i></dt>
63
<dt><a id='PIL.ImageChops.blend-function' name='PIL.ImageChops.blend-function'><b>blend(image1, image2, alpha)</b></a> [<a href='#PIL.ImageChops.blend-function'>#</a>]</dt>
65
<p>Blend images using constant transparency weight.
67
Same as the <b>blend</b> function in the <b>Image</b> module.
69
<dt><a id='PIL.ImageChops.composite-function' name='PIL.ImageChops.composite-function'><b>composite(image1, image2, mask)</b></a> [<a href='#PIL.ImageChops.composite-function'>#</a>]</dt>
71
<p>Create composite using transparency mask.
73
Same as the <b>composite</b> function in the <b>Image</b> module.
75
<dt><a id='PIL.ImageChops.constant-function' name='PIL.ImageChops.constant-function'><b>constant(image, value)</b></a> [<a href='#PIL.ImageChops.constant-function'>#</a>]</dt>
89
<dt><a id='PIL.ImageChops.darker-function' name='PIL.ImageChops.darker-function'><b>darker(image1, image2)</b></a> [<a href='#PIL.ImageChops.darker-function'>#</a>]</dt>
91
<p>Compare images, and return darker pixel value
92
(min(image1, image2)).
94
Compares the two images, pixel by pixel, and returns a new image
95
containing the darker values.
98
<dt><i>image1</i></dt>
101
<dt><i>image1</i></dt>
109
<dt><a id='PIL.ImageChops.difference-function' name='PIL.ImageChops.difference-function'><b>difference(image1, image2)</b></a> [<a href='#PIL.ImageChops.difference-function'>#</a>]</dt>
111
<p>Calculate absolute difference
112
(abs(image1 - image2)).
114
Returns the absolute value of the difference between the two images.
117
<dt><i>image1</i></dt>
120
<dt><i>image1</i></dt>
128
<dt><a id='PIL.ImageChops.duplicate-function' name='PIL.ImageChops.duplicate-function'><b>duplicate(image)</b></a> [<a href='#PIL.ImageChops.duplicate-function'>#</a>]</dt>
131
<dt><i>image</i></dt>
139
<dt><a id='PIL.ImageChops.invert-function' name='PIL.ImageChops.invert-function'><b>invert(image)</b></a> [<a href='#PIL.ImageChops.invert-function'>#</a>]</dt>
142
<dt><i>image</i></dt>
150
<dt><a id='PIL.ImageChops.lighter-function' name='PIL.ImageChops.lighter-function'><b>lighter(image1, image2)</b></a> [<a href='#PIL.ImageChops.lighter-function'>#</a>]</dt>
152
<p>Compare images, and return lighter pixel value
153
(max(image1, image2)).
155
Compares the two images, pixel by pixel, and returns a new image
156
containing the lighter values.
159
<dt><i>image1</i></dt>
162
<dt><i>image1</i></dt>
170
<dt><a id='PIL.ImageChops.logical_and-function' name='PIL.ImageChops.logical_and-function'><b>logical_and(image1, image2)</b></a> [<a href='#PIL.ImageChops.logical_and-function'>#</a>]</dt>
173
<dt><a id='PIL.ImageChops.logical_or-function' name='PIL.ImageChops.logical_or-function'><b>logical_or(image1, image2)</b></a> [<a href='#PIL.ImageChops.logical_or-function'>#</a>]</dt>
176
<dt><a id='PIL.ImageChops.logical_xor-function' name='PIL.ImageChops.logical_xor-function'><b>logical_xor(image1, image2)</b></a> [<a href='#PIL.ImageChops.logical_xor-function'>#</a>]</dt>
179
<dt><a id='PIL.ImageChops.multiply-function' name='PIL.ImageChops.multiply-function'><b>multiply(image1, image2)</b></a> [<a href='#PIL.ImageChops.multiply-function'>#</a>]</dt>
181
<p>Superimpose positive images
182
(image1 * image2 / MAX).
184
Superimposes two images on top of each other. If you multiply an
185
image with a solid black image, the result is black. If you multiply
186
with a solid white image, the image is unaffected.
189
<dt><i>image1</i></dt>
192
<dt><i>image1</i></dt>
200
<dt><a id='PIL.ImageChops.offset-function' name='PIL.ImageChops.offset-function'><b>offset(image, xoffset, yoffset=None)</b></a> [<a href='#PIL.ImageChops.offset-function'>#</a>]</dt>
202
<p>Offset image data.
204
Returns a copy of the image where data has been offset by the given
205
distances. Data wraps around the edges. If yoffset is omitted, it
206
is assumed to be equal to xoffset.
209
<dt><i>image</i></dt>
212
<dt><i>xoffset</i></dt>
215
<dt><i>yoffset</i></dt>
223
<dt><a id='PIL.ImageChops.screen-function' name='PIL.ImageChops.screen-function'><b>screen(image1, image2)</b></a> [<a href='#PIL.ImageChops.screen-function'>#</a>]</dt>
225
<p>Superimpose negative images
226
(MAX - ((MAX - image1) * (MAX - image2) / MAX)).
228
Superimposes two inverted images on top of each other.
231
<dt><i>image1</i></dt>
234
<dt><i>image1</i></dt>
242
<dt><a id='PIL.ImageChops.subtract-function' name='PIL.ImageChops.subtract-function'><b>subtract(image1, image2, scale=1.0, offset=0)</b></a> [<a href='#PIL.ImageChops.subtract-function'>#</a>]</dt>
245
((image1 - image2) / scale + offset).
247
Subtracts two images, dividing the result by scale and adding the
248
offset. If omitted, scale defaults to 1.0, and offset to 0.0.
251
<dt><i>image1</i></dt>
254
<dt><i>image1</i></dt>
262
<dt><a id='PIL.ImageChops.subtract_modulo-function' name='PIL.ImageChops.subtract_modulo-function'><b>subtract_modulo(image1, image2)</b></a> [<a href='#PIL.ImageChops.subtract_modulo-function'>#</a>]</dt>
264
<p>Subtract images without clipping
265
((image1 - image2) % MAX).
267
Subtracts two images, without clipping the result.
270
<dt><i>image1</i></dt>
273
<dt><i>image1</i></dt>