File: test_format_lab.py

package info (click to toggle)
pillow 12.1.0-1
  • links: PTS
  • area: main
  • in suites: sid
  • size: 72,560 kB
  • sloc: python: 49,748; ansic: 38,748; makefile: 302; sh: 168; javascript: 85
file content (40 lines) | stat: -rw-r--r-- 941 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from __future__ import annotations

from PIL import Image


def test_white() -> None:
    with Image.open("Tests/images/lab.tif") as i:
        i.load()

        assert i.mode == "LAB"

        assert i.getbands() == ("L", "A", "B")

        k = i.getpixel((0, 0))

        L = i.get_flattened_data(0)
        a = i.get_flattened_data(1)
        b = i.get_flattened_data(2)

    assert k == (255, 128, 128)

    assert L == (255,) * 100
    assert a == (128,) * 100
    assert b == (128,) * 100


def test_green() -> None:
    # l= 50 (/100), a = -100 (-128 .. 128) b=0 in PS
    # == RGB: 0, 152, 117
    with Image.open("Tests/images/lab-green.tif") as i:
        k = i.getpixel((0, 0))
    assert k == (128, 28, 128)


def test_red() -> None:
    # l= 50 (/100), a = 100 (-128 .. 128) b=0 in PS
    # == RGB: 255, 0, 124
    with Image.open("Tests/images/lab-red.tif") as i:
        k = i.getpixel((0, 0))
    assert k == (128, 228, 128)