mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-30 10:43:16 +03:00
add hardlight and softlight chops
This commit is contained in:
parent
319f5409fe
commit
705140cc2c
|
@ -363,7 +363,7 @@ def test_subtract_modulo_no_clip():
|
|||
new = ImageChops.subtract_modulo(im1, im2)
|
||||
|
||||
# Assert
|
||||
assert new.getpixel((50, 50)) == (241, 167, 127)
|
||||
self.assertEqual(new.getpixel((50, 50)), (241, 167, 127))
|
||||
|
||||
|
||||
def test_softlight(self):
|
||||
|
@ -392,19 +392,6 @@ 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 = []
|
||||
|
|
|
@ -138,6 +138,27 @@ 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
|
||||
|
||||
:rtype: :py:class:`~PIL.Image.Image`
|
||||
"""
|
||||
|
||||
image1.load()
|
||||
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
|
||||
|
||||
:rtype: :py:class:`~PIL.Image.Image`
|
||||
"""
|
||||
|
||||
image1.load()
|
||||
image2.load()
|
||||
return image1._new(image1.im.chop_hardlight(image2.im))
|
||||
|
||||
def softlight(image1, image2):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user