mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
updated test to assert equality with reference images
This commit is contained in:
parent
b19c460568
commit
837d868333
BIN
Tests/images/bw_gradient.png
Normal file
BIN
Tests/images/bw_gradient.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
Tests/images/bw_gradient_2color.png
Normal file
BIN
Tests/images/bw_gradient_2color.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 179 B |
BIN
Tests/images/bw_gradient_3color.png
Normal file
BIN
Tests/images/bw_gradient_3color.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 246 B |
|
@ -1,6 +1,7 @@
|
|||
from helper import unittest, PillowTestCase, hopper
|
||||
|
||||
from PIL import ImageOps
|
||||
from PIL import Image
|
||||
|
||||
|
||||
class TestImageOps(PillowTestCase):
|
||||
|
@ -97,18 +98,23 @@ class TestImageOps(PillowTestCase):
|
|||
def test_colorize(self):
|
||||
# Test the colorizing function
|
||||
|
||||
# Grab test image
|
||||
i = hopper("L").resize((15, 16))
|
||||
# Grab test image (10px black, 256px gradient, 10px white)
|
||||
im = Image.open("Tests/images/bw_gradient.png")
|
||||
im = im.convert("L")
|
||||
|
||||
# Test original 2-color functionality
|
||||
ImageOps.colorize(i, 'green', 'red')
|
||||
out_2color = ImageOps.colorize(im, 'red', 'green')
|
||||
|
||||
# Test new three color functionality (cyanotype colors)
|
||||
ImageOps.colorize(i,
|
||||
(32, 37, 79),
|
||||
(255, 255, 255),
|
||||
(35, 52, 121),
|
||||
40)
|
||||
# Test new three color functionality, with midpoint offset
|
||||
out_3color = ImageOps.colorize(im, 'red', 'green', 'yellow', 100)
|
||||
|
||||
# Assert 2-color
|
||||
ref_2color = Image.open("Tests/images/bw_gradient_2color.png")
|
||||
self.assert_image_equal(out_2color, ref_2color)
|
||||
|
||||
# Assert 3-color
|
||||
ref_3color = Image.open("Tests/images/bw_gradient_3color.png")
|
||||
self.assert_image_equal(out_3color, ref_3color)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in New Issue
Block a user