Pillow/Tests/test_image_getextrema.py

30 lines
1023 B
Python
Raw Normal View History

from PIL import Image
from .helper import PillowTestCase, hopper
2014-06-10 13:10:47 +04:00
class TestImageGetExtrema(PillowTestCase):
2014-06-10 13:10:47 +04:00
def test_extrema(self):
2014-06-10 13:10:47 +04:00
def extrema(mode):
return hopper(mode).getextrema()
2014-06-10 13:10:47 +04:00
self.assertEqual(extrema("1"), (0, 255))
self.assertEqual(extrema("L"), (0, 255))
2019-05-08 14:58:33 +03:00
self.assertEqual(extrema("I"), (150, 65280))
self.assertEqual(extrema("F"), (0, 255))
self.assertEqual(extrema("P"), (0, 225)) # fixed palette
2014-06-10 13:10:47 +04:00
self.assertEqual(
extrema("RGB"), ((0, 255), (0, 255), (0, 255)))
2014-06-10 13:10:47 +04:00
self.assertEqual(
extrema("RGBA"), ((0, 255), (0, 255), (0, 255), (255, 255)))
2014-06-10 13:10:47 +04:00
self.assertEqual(
2018-10-02 11:55:28 +03:00
extrema("CMYK"), ((0, 255), (0, 255), (0, 255), (0, 0)))
2019-05-08 14:58:33 +03:00
self.assertEqual(extrema("I;16"), (150, 65280))
def test_true_16(self):
im = Image.open("Tests/images/16_bit_noise.tif")
self.assertEqual(im.mode, 'I;16')
extrema = im.getextrema()
self.assertEqual(extrema, (106, 285))