PIL.Image.Image.paste - Serbipunk/notes GitHub Wiki
paste(self, im, box=None, mask=None) unbound PIL.Image.Image method
Pastes another image into this image. 将一张图片叠在另一张图片上
The box argument is either a 2-tuple giving the upper left corner, a 4-tuple defining the
left, upper, right, and lower pixel coordinate, or None (same as
(0, 0)).
box参数可以是2个角点坐标的列表,或者4个元组,存储左上右下。
See :ref:`coordinate-system`. 具体详见 ref:`coordinate-system`
If a 4-tuple is given, the size of the pasted image must match the size of the region.
如果给出BOX的4元组,叠图上层图片必须满足box的尺寸e
If the modes don't match, the pasted image is converted to the mode of this image (see the :py:meth:`~PIL.Image.Image.convert` method for details).
Instead of an image, the source can be a integer or tuple
containing pixel values. The method then fills the region
with the given color. When creating RGB images, you can
also use color strings as supported by the ImageColor module.
If a mask is given, this method updates only the regions
indicated by the mask. You can use either "1", "L" or "RGBA"
images (in the latter case, the alpha band is used as mask).
Where the mask is 255, the given image is copied as is. Where
the mask is 0, the current value is preserved. Intermediate
values will mix the two images together, including their alpha
channels if they have them.
See :py:meth:`~PIL.Image.Image.alpha_composite` if you want to
combine images with respect to their alpha channels.
:param im: Source image or pixel value (integer or tuple).
:param box: An optional 4-tuple giving the region to paste into.
If a 2-tuple is used instead, it's treated as the upper left
corner. If omitted or None, the source is pasted into the
upper left corner.
If an image is given as the second argument and there is no
third, the box defaults to (0, 0), and the second argument
is interpreted as a mask image.
:param mask: An optional mask image.