add Overlay chop

This commit is contained in:
Dag Wästberg 2019-11-22 14:30:43 +01:00 committed by Andrew Murray
parent 705140cc2c
commit 23c9da5264
2 changed files with 18 additions and 2 deletions

View File

@ -392,6 +392,19 @@ def test_hardlight(self):
self.assertEqual(new.getpixel((15, 100)), (1, 1, 2))
def test_overlay(self):
# Arrange
im1 = Image.open("Tests/images/hopper.png")
im2 = Image.open("Tests/images/hopper-XYZ.png")
# Act
new = ImageChops.overlay(im1, im2)
# Assert
self.assertEqual(new.getpixel((64, 64)), (159, 50, 27))
self.assertEqual(new.getpixel((15, 100)), (1, 1, 2))
def test_logical():
def table(op, a, b):
out = []

View File

@ -138,9 +138,10 @@ def screen(image1, image2):
image2.load()
return image1._new(image1.im.chop_screen(image2.im))
def softlight(image1, image2):
"""
Superimposes two images on top of each other using the Soft Light algorithm
Superimposes two images on top of each other using the Soft Light algorithm
:rtype: :py:class:`~PIL.Image.Image`
"""
@ -149,9 +150,10 @@ def softlight(image1, image2):
image2.load()
return image1._new(image1.im.chop_softlight(image2.im))
def hardlight(image1, image2):
"""
Superimposes two images on top of each other using the Hard Light algorithm
Superimposes two images on top of each other using the Hard Light algorithm
:rtype: :py:class:`~PIL.Image.Image`
"""
@ -160,6 +162,7 @@ def hardlight(image1, image2):
image2.load()
return image1._new(image1.im.chop_hardlight(image2.im))
def softlight(image1, image2):
"""
Superimposes two images on top of each other using the Soft Light algorithm