mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
32 lines
1000 B
Python
32 lines
1000 B
Python
from __future__ import annotations
|
|
|
|
from PIL import Image
|
|
|
|
from .helper import hopper
|
|
|
|
|
|
def test_sanity() -> None:
|
|
im = hopper()
|
|
|
|
projection = im.getprojection()
|
|
|
|
assert len(projection) == 2
|
|
assert len(projection[0]) == im.size[0]
|
|
assert len(projection[1]) == im.size[1]
|
|
|
|
# 8-bit image
|
|
im = Image.new("L", (10, 10))
|
|
assert im.getprojection()[0] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
im.paste(255, (2, 4, 8, 6))
|
|
assert im.getprojection()[0] == [0, 0, 1, 1, 1, 1, 1, 1, 0, 0]
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]
|
|
|
|
# 32-bit image
|
|
im = Image.new("RGB", (10, 10))
|
|
assert im.getprojection()[0] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
|
im.paste(255, (2, 4, 8, 6))
|
|
assert im.getprojection()[0] == [0, 0, 1, 1, 1, 1, 1, 1, 0, 0]
|
|
assert im.getprojection()[1] == [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]
|