2121
2222
2323def constant (image : Image .Image , value : int ) -> Image .Image :
24- """Fill a channel with a given gray level.
25-
26- :rtype: :py:class:`~PIL.Image.Image`
27- """
24+ """Fill a channel with a given gray level."""
2825
2926 return Image .new ("L" , image .size , value )
3027
3128
3229def duplicate (image : Image .Image ) -> Image .Image :
33- """Copy a channel. Alias for :py:meth:`PIL.Image.Image.copy`.
34-
35- :rtype: :py:class:`~PIL.Image.Image`
36- """
30+ """Copy a channel. Alias for :py:meth:`PIL.Image.Image.copy`."""
3731
3832 return image .copy ()
3933
@@ -43,8 +37,6 @@ def invert(image: Image.Image) -> Image.Image:
4337 Invert an image (channel). ::
4438
4539 out = MAX - image
46-
47- :rtype: :py:class:`~PIL.Image.Image`
4840 """
4941
5042 image .load ()
@@ -57,8 +49,6 @@ def lighter(image1: Image.Image, image2: Image.Image) -> Image.Image:
5749 the lighter values. ::
5850
5951 out = max(image1, image2)
60-
61- :rtype: :py:class:`~PIL.Image.Image`
6252 """
6353
6454 image1 .load ()
@@ -72,8 +62,6 @@ def darker(image1: Image.Image, image2: Image.Image) -> Image.Image:
7262 the darker values. ::
7363
7464 out = min(image1, image2)
75-
76- :rtype: :py:class:`~PIL.Image.Image`
7765 """
7866
7967 image1 .load ()
@@ -87,8 +75,6 @@ def difference(image1: Image.Image, image2: Image.Image) -> Image.Image:
8775 images. ::
8876
8977 out = abs(image1 - image2)
90-
91- :rtype: :py:class:`~PIL.Image.Image`
9278 """
9379
9480 image1 .load ()
@@ -104,8 +90,6 @@ def multiply(image1: Image.Image, image2: Image.Image) -> Image.Image:
10490 you multiply with a solid white image, the image is unaffected. ::
10591
10692 out = image1 * image2 / MAX
107-
108- :rtype: :py:class:`~PIL.Image.Image`
10993 """
11094
11195 image1 .load ()
@@ -118,8 +102,6 @@ def screen(image1: Image.Image, image2: Image.Image) -> Image.Image:
118102 Superimposes two inverted images on top of each other. ::
119103
120104 out = MAX - ((MAX - image1) * (MAX - image2) / MAX)
121-
122- :rtype: :py:class:`~PIL.Image.Image`
123105 """
124106
125107 image1 .load ()
@@ -130,8 +112,6 @@ def screen(image1: Image.Image, image2: Image.Image) -> Image.Image:
130112def soft_light (image1 : Image .Image , image2 : Image .Image ) -> Image .Image :
131113 """
132114 Superimposes two images on top of each other using the Soft Light algorithm
133-
134- :rtype: :py:class:`~PIL.Image.Image`
135115 """
136116
137117 image1 .load ()
@@ -142,8 +122,6 @@ def soft_light(image1: Image.Image, image2: Image.Image) -> Image.Image:
142122def hard_light (image1 : Image .Image , image2 : Image .Image ) -> Image .Image :
143123 """
144124 Superimposes two images on top of each other using the Hard Light algorithm
145-
146- :rtype: :py:class:`~PIL.Image.Image`
147125 """
148126
149127 image1 .load ()
@@ -154,8 +132,6 @@ def hard_light(image1: Image.Image, image2: Image.Image) -> Image.Image:
154132def overlay (image1 : Image .Image , image2 : Image .Image ) -> Image .Image :
155133 """
156134 Superimposes two images on top of each other using the Overlay algorithm
157-
158- :rtype: :py:class:`~PIL.Image.Image`
159135 """
160136
161137 image1 .load ()
@@ -168,11 +144,11 @@ def add(
168144) -> Image .Image :
169145 """
170146 Adds two images, dividing the result by scale and adding the
171- offset. If omitted, scale defaults to 1.0, and offset to 0.0. ::
147+ offset. If omitted, scale defaults to 1.0, and offset to 0.0.
172148
173- out = ((image1 + image2) / scale + offset)
149+ ::
174150
175- :rtype: :py:class:`~PIL.Image.Image`
151+ out = ((image1 + image2) / scale + offset)
176152 """
177153
178154 image1 .load ()
@@ -185,11 +161,11 @@ def subtract(
185161) -> Image .Image :
186162 """
187163 Subtracts two images, dividing the result by scale and adding the offset.
188- If omitted, scale defaults to 1.0, and offset to 0.0. ::
164+ If omitted, scale defaults to 1.0, and offset to 0.0.
189165
190- out = ((image1 - image2) / scale + offset)
166+ ::
191167
192- :rtype: :py:class:`~PIL.Image.Image`
168+ out = ((image1 - image2) / scale + offset)
193169 """
194170
195171 image1 .load ()
@@ -198,11 +174,11 @@ def subtract(
198174
199175
200176def add_modulo (image1 : Image .Image , image2 : Image .Image ) -> Image .Image :
201- """Add two images, without clipping the result. ::
177+ """Add two images, without clipping the result.
202178
203- out = ((image1 + image2) % MAX)
179+ ::
204180
205- :rtype: :py:class:`~PIL.Image.Image`
181+ out = ((image1 + image2) % MAX)
206182 """
207183
208184 image1 .load ()
@@ -211,11 +187,11 @@ def add_modulo(image1: Image.Image, image2: Image.Image) -> Image.Image:
211187
212188
213189def subtract_modulo (image1 : Image .Image , image2 : Image .Image ) -> Image .Image :
214- """Subtract two images, without clipping the result. ::
190+ """Subtract two images, without clipping the result.
215191
216- out = ((image1 - image2) % MAX)
192+ ::
217193
218- :rtype: :py:class:`~PIL.Image.Image`
194+ out = ((image1 - image2) % MAX)
219195 """
220196
221197 image1 .load ()
@@ -232,8 +208,6 @@ def logical_and(image1: Image.Image, image2: Image.Image) -> Image.Image:
232208 as the second image. ::
233209
234210 out = ((image1 and image2) % MAX)
235-
236- :rtype: :py:class:`~PIL.Image.Image`
237211 """
238212
239213 image1 .load ()
@@ -247,8 +221,6 @@ def logical_or(image1: Image.Image, image2: Image.Image) -> Image.Image:
247221 Both of the images must have mode "1". ::
248222
249223 out = ((image1 or image2) % MAX)
250-
251- :rtype: :py:class:`~PIL.Image.Image`
252224 """
253225
254226 image1 .load ()
@@ -262,8 +234,6 @@ def logical_xor(image1: Image.Image, image2: Image.Image) -> Image.Image:
262234 Both of the images must have mode "1". ::
263235
264236 out = ((bool(image1) != bool(image2)) % MAX)
265-
266- :rtype: :py:class:`~PIL.Image.Image`
267237 """
268238
269239 image1 .load ()
@@ -272,10 +242,9 @@ def logical_xor(image1: Image.Image, image2: Image.Image) -> Image.Image:
272242
273243
274244def blend (image1 : Image .Image , image2 : Image .Image , alpha : float ) -> Image .Image :
275- """Blend images using constant transparency weight. Alias for
276- :py:func:`PIL.Image.blend`.
245+ """Blend images using constant transparency weight.
277246
278- :rtype: :py:class:`~ PIL.Image.Image`
247+ Alias for :py:func:` PIL.Image.blend`.
279248 """
280249
281250 return Image .blend (image1 , image2 , alpha )
@@ -284,10 +253,9 @@ def blend(image1: Image.Image, image2: Image.Image, alpha: float) -> Image.Image
284253def composite (
285254 image1 : Image .Image , image2 : Image .Image , mask : Image .Image
286255) -> Image .Image :
287- """Create composite using transparency mask. Alias for
288- :py:func:`PIL.Image.composite`.
256+ """Create composite using transparency mask.
289257
290- :rtype: :py:class:`~ PIL.Image.Image`
258+ Alias for :py:func:` PIL.Image.composite`.
291259 """
292260
293261 return Image .composite (image1 , image2 , mask )
@@ -302,7 +270,6 @@ def offset(image: Image.Image, xoffset: int, yoffset: int | None = None) -> Imag
302270 :param xoffset: The horizontal distance.
303271 :param yoffset: The vertical distance. If omitted, both
304272 distances are set to the same value.
305- :rtype: :py:class:`~PIL.Image.Image`
306273 """
307274
308275 if yoffset is None :
0 commit comments