2020-01-05 00:07:59 +03:00
|
|
|
import pytest
|
2018-09-17 18:30:42 +03:00
|
|
|
from PIL import Image
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2020-01-05 00:07:59 +03:00
|
|
|
from .helper import PillowTestCase, hopper, is_big_endian, on_ci
|
2012-10-16 00:26:38 +04:00
|
|
|
|
|
|
|
|
2014-06-10 13:10:47 +04:00
|
|
|
class TestImageGetExtrema(PillowTestCase):
|
2020-01-05 00:07:59 +03:00
|
|
|
@pytest.mark.xfail(is_big_endian() and on_ci(), reason="Fails on big-endian")
|
2014-06-10 13:10:47 +04:00
|
|
|
def test_extrema(self):
|
|
|
|
def extrema(mode):
|
2014-09-05 14:03:56 +04:00
|
|
|
return hopper(mode).getextrema()
|
2014-06-10 13:10:47 +04:00
|
|
|
|
|
|
|
self.assertEqual(extrema("1"), (0, 255))
|
2019-12-31 04:12:50 +03:00
|
|
|
self.assertEqual(extrema("L"), (1, 255))
|
|
|
|
self.assertEqual(extrema("I"), (1, 255))
|
|
|
|
self.assertEqual(extrema("F"), (1, 255))
|
2014-09-14 21:00:13 +04:00
|
|
|
self.assertEqual(extrema("P"), (0, 225)) # fixed palette
|
2019-06-13 18:54:24 +03:00
|
|
|
self.assertEqual(extrema("RGB"), ((0, 255), (0, 255), (0, 255)))
|
|
|
|
self.assertEqual(extrema("RGBA"), ((0, 255), (0, 255), (0, 255), (255, 255)))
|
|
|
|
self.assertEqual(extrema("CMYK"), ((0, 255), (0, 255), (0, 255), (0, 0)))
|
2019-12-31 04:12:50 +03:00
|
|
|
self.assertEqual(extrema("I;16"), (1, 255))
|
2018-09-17 18:30:42 +03:00
|
|
|
|
2020-01-05 00:07:59 +03:00
|
|
|
@pytest.mark.xfail(is_big_endian() and on_ci(), reason="Fails on big-endian")
|
2018-09-17 18:30:42 +03:00
|
|
|
def test_true_16(self):
|
2019-11-25 23:03:23 +03:00
|
|
|
with Image.open("Tests/images/16_bit_noise.tif") as im:
|
|
|
|
self.assertEqual(im.mode, "I;16")
|
|
|
|
extrema = im.getextrema()
|
2018-09-17 18:30:42 +03:00
|
|
|
self.assertEqual(extrema, (106, 285))
|