mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46: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 helper import unittest, PillowTestCase, hopper
|
||||||
|
|
||||||
from PIL import ImageOps
|
from PIL import ImageOps
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
class TestImageOps(PillowTestCase):
|
class TestImageOps(PillowTestCase):
|
||||||
|
@ -97,18 +98,23 @@ class TestImageOps(PillowTestCase):
|
||||||
def test_colorize(self):
|
def test_colorize(self):
|
||||||
# Test the colorizing function
|
# Test the colorizing function
|
||||||
|
|
||||||
# Grab test image
|
# Grab test image (10px black, 256px gradient, 10px white)
|
||||||
i = hopper("L").resize((15, 16))
|
im = Image.open("Tests/images/bw_gradient.png")
|
||||||
|
im = im.convert("L")
|
||||||
|
|
||||||
# Test original 2-color functionality
|
# Test original 2-color functionality
|
||||||
ImageOps.colorize(i, 'green', 'red')
|
out_2color = ImageOps.colorize(im, 'red', 'green')
|
||||||
|
|
||||||
# Test new three color functionality (cyanotype colors)
|
# Test new three color functionality, with midpoint offset
|
||||||
ImageOps.colorize(i,
|
out_3color = ImageOps.colorize(im, 'red', 'green', 'yellow', 100)
|
||||||
(32, 37, 79),
|
|
||||||
(255, 255, 255),
|
# Assert 2-color
|
||||||
(35, 52, 121),
|
ref_2color = Image.open("Tests/images/bw_gradient_2color.png")
|
||||||
40)
|
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__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue
Block a user