📜  Python PIL | ImageChops.screen() 和 ImageChops.offset() 方法

📅  最后修改于: 2022-05-13 01:54:51.549000             🧑  作者: Mango

Python PIL | ImageChops.screen() 和 ImageChops.offset() 方法

PIL 是Python Imaging Library,它为Python解释器提供了图像编辑功能。

ImageChops.screen() 方法 –

该方法用于将两个倒置图像叠加在一起。

Syntax: ImageChops.screen(image1, image2)

Parameters:
image1 first image
image2 second image

Return Value: An Image

Python3
# This will import Image and ImageChops modules
from PIL import Image, ImageChops
 
# Opening Images
im = Image.open(r"C:\Users\Admin\Pictures\images.png")
im2 = Image.open(r"C:\Users\Admin\Pictures\download.PNG")
 
# superimposing images im and im2
im3 = ImageChops.screen(im, im2)
 
# showing resultant image
im3.show()


Python3
# This will import Image and ImageChops modules
from PIL import Image, ImageChops
 
# Opening Images
im = Image.open(r"C:\Users\Admin\Pictures\images.png")
im2 = Image.open(r"C:\Users\Admin\Pictures\download.PNG")
 
# Here, xoffset is given 100
# yoffset wil automatically set to 100
im3 = ImageChops.offset(im, 140)
 
# showing resultant image
im3.show()


输出:

ImageChops.offset() 方法 –

此方法返回图像的副本,其中数据已偏移给定距离。数据环绕边缘。如果省略 yoffset,则假定它等于 xoffset。

Python3

# This will import Image and ImageChops modules
from PIL import Image, ImageChops
 
# Opening Images
im = Image.open(r"C:\Users\Admin\Pictures\images.png")
im2 = Image.open(r"C:\Users\Admin\Pictures\download.PNG")
 
# Here, xoffset is given 100
# yoffset wil automatically set to 100
im3 = ImageChops.offset(im, 140)
 
# showing resultant image
im3.show()

输出: