diff --git a/Tests/test_image_filter.py b/Tests/test_image_filter.py index c8a397e7e..88aae419e 100644 --- a/Tests/test_image_filter.py +++ b/Tests/test_image_filter.py @@ -95,26 +95,40 @@ class TestImageFilter(PillowTestCase): self.assertEqual(rankfilter.rank, 2) def test_consistency_3x3(self): - im = Image.open("Tests/images/hopper.bmp") - emboss = im.filter(ImageFilter.Kernel((3, 3), - (-1, -1, 0, - -1, 0, 1, - 0, 1, 1), .3)) + source = Image.open("Tests/images/hopper.bmp") + reference = Image.open("Tests/images/hopper_emboss.bmp") + kernel = ImageFilter.Kernel((3, 3), + (-1, -1, 0, + -1, 0, 1, + 0, 1, 1), .3) + source = source.split() * 2 + reference = reference.split() * 2 - self.assert_image_equal( - emboss, Image.open("Tests/images/hopper_emboss.bmp")) + for mode in ['L', 'LA', 'RGB', 'CMYK']: + print mode + self.assert_image_equal( + Image.merge(mode, source[:len(mode)]).filter(kernel), + Image.merge(mode, reference[:len(mode)]), + ) def test_consistency_5x5(self): - im = Image.open("Tests/images/hopper.bmp") - emboss = im.filter(ImageFilter.Kernel((5, 5), - (-1, -1, -1, -1, 0, - -1, -1, -1, 0, 1, - -1, -1, 0, 1, 1, - -1, 0, 1, 1, 1, - 0, 1, 1, 1, 1), 0.3)) + source = Image.open("Tests/images/hopper.bmp") + reference = Image.open("Tests/images/hopper_emboss_more.bmp") + kernel = ImageFilter.Kernel((5, 5), + (-1, -1, -1, -1, 0, + -1, -1, -1, 0, 1, + -1, -1, 0, 1, 1, + -1, 0, 1, 1, 1, + 0, 1, 1, 1, 1), 0.3) + source = source.split() * 2 + reference = reference.split() * 2 - self.assert_image_equal( - emboss, Image.open("Tests/images/hopper_emboss_more.bmp")) + for mode in ['L', 'LA', 'RGB', 'CMYK']: + print mode + self.assert_image_equal( + Image.merge(mode, source[:len(mode)]).filter(kernel), + Image.merge(mode, reference[:len(mode)]), + ) if __name__ == '__main__':