2023-12-21 14:13:31 +03:00
|
|
|
from __future__ import annotations
|
2024-01-20 14:23:03 +03:00
|
|
|
|
2018-09-17 18:30:42 +03:00
|
|
|
from PIL import Image
|
2019-07-06 23:40:53 +03:00
|
|
|
|
2020-02-29 12:29:28 +03:00
|
|
|
from .helper import hopper
|
2012-10-16 00:26:38 +04:00
|
|
|
|
|
|
|
|
2024-01-31 12:12:58 +03:00
|
|
|
def test_extrema() -> None:
|
2020-01-27 14:46:52 +03:00
|
|
|
def extrema(mode):
|
|
|
|
return hopper(mode).getextrema()
|
2014-06-10 13:10:47 +04:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
assert extrema("1") == (0, 255)
|
|
|
|
assert extrema("L") == (1, 255)
|
|
|
|
assert extrema("I") == (1, 255)
|
|
|
|
assert extrema("F") == (1, 255)
|
|
|
|
assert extrema("P") == (0, 225) # fixed palette
|
|
|
|
assert extrema("RGB") == ((0, 255), (0, 255), (0, 255))
|
|
|
|
assert extrema("RGBA") == ((0, 255), (0, 255), (0, 255), (255, 255))
|
|
|
|
assert extrema("CMYK") == ((0, 255), (0, 255), (0, 255), (0, 0))
|
|
|
|
assert extrema("I;16") == (1, 255)
|
2018-09-17 18:30:42 +03:00
|
|
|
|
2020-01-27 14:46:52 +03:00
|
|
|
|
2024-01-31 12:12:58 +03:00
|
|
|
def test_true_16() -> None:
|
2020-01-27 14:46:52 +03:00
|
|
|
with Image.open("Tests/images/16_bit_noise.tif") as im:
|
|
|
|
assert im.mode == "I;16"
|
|
|
|
extrema = im.getextrema()
|
|
|
|
assert extrema == (106, 285)
|