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>
77
<p>Return an image with the same size as the given image, but filled
78
with the given pixel value.</p>
91
<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>
93
<p>Compare images, and return darker pixel value
94
(min(image1, image2)).
96
Compares the two images, pixel by pixel, and returns a new image
97
containing the darker values.
100
<dt><i>image1</i></dt>
103
<dt><i>image1</i></dt>
108
An image object.</dd>
111
<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>
113
<p>Calculate absolute difference
114
(abs(image1 - image2)).
116
Returns the absolute value of the difference between the two images.
119
<dt><i>image1</i></dt>
122
<dt><i>image1</i></dt>
127
An image object.</dd>
130
<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>
134
<dt><i>image</i></dt>
139
A copy of the source image.</dd>
142
<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>
147
<dt><i>image</i></dt>
152
An image object.</dd>
155
<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>
157
<p>Compare images, and return lighter pixel value
158
(max(image1, image2)).
160
Compares the two images, pixel by pixel, and returns a new image
161
containing the lighter values.
164
<dt><i>image1</i></dt>
167
<dt><i>image1</i></dt>
172
An image object.</dd>
175
<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>
178
(image1 and image2).</p>
180
<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>
183
(image1 or image2).</p>
185
<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>
188
(image1 xor image2).</p>
190
<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>
192
<p>Superimpose positive images
193
(image1 * image2 / MAX).
195
Superimposes two images on top of each other. If you multiply an
196
image with a solid black image, the result is black. If you multiply
197
with a solid white image, the image is unaffected.
200
<dt><i>image1</i></dt>
203
<dt><i>image1</i></dt>
208
An image object.</dd>
211
<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>
213
<p>Offset image data.
215
Returns a copy of the image where data has been offset by the given
216
distances. Data wraps around the edges. If yoffset is omitted, it
217
is assumed to be equal to xoffset.
220
<dt><i>image</i></dt>
223
<dt><i>xoffset</i></dt>
225
The horizontal distance.</dd>
226
<dt><i>yoffset</i></dt>
228
The vertical distance. If omitted, both
229
distances are set to the same value.</dd>
232
An Image object.</dd>
235
<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>
237
<p>Superimpose negative images
238
(MAX - ((MAX - image1) * (MAX - image2) / MAX)).
240
Superimposes two inverted images on top of each other.
243
<dt><i>image1</i></dt>
246
<dt><i>image1</i></dt>
251
An image object.</dd>
254
<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>
257
((image1 - image2) / scale + offset).
259
Subtracts two images, dividing the result by scale and adding the
260
offset. If omitted, scale defaults to 1.0, and offset to 0.0.
263
<dt><i>image1</i></dt>
266
<dt><i>image1</i></dt>
271
An image object.</dd>
274
<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>
276
<p>Subtract images without clipping
277
((image1 - image2) % MAX).
279
Subtracts two images, without clipping the result.
282
<dt><i>image1</i></dt>
285
<dt><i>image1</i></dt>
290
An image object.</dd>