1
from __future__ import annotations
9
with warnings.catch_warnings():
10
warnings.simplefilter("ignore", category=DeprecationWarning)
11
from PIL import ImageQt
13
from .helper import assert_image_equal, hopper
15
pytestmark = pytest.mark.skipif(
16
not ImageQt.qt_is_installed, reason="Qt bindings are not installed"
19
ims: list[Image.Image] = []
22
def setup_module() -> None:
24
ims.append(Image.open("Tests/images/transparent.png"))
25
ims.append(Image.open("Tests/images/7x13.png"))
28
def teardown_module() -> None:
33
def roundtrip(expected: Image.Image) -> None:
35
intermediate = expected.toqimage()
37
result = ImageQt.fromqimage(intermediate)
39
if intermediate.hasAlphaChannel():
40
assert_image_equal(result, expected.convert("RGBA"))
42
assert_image_equal(result, expected.convert("RGB"))
45
def test_sanity_1() -> None:
47
roundtrip(im.convert("1"))
50
def test_sanity_rgb() -> None:
52
roundtrip(im.convert("RGB"))
55
def test_sanity_rgba() -> None:
57
roundtrip(im.convert("RGBA"))
60
def test_sanity_l() -> None:
62
roundtrip(im.convert("L"))
65
def test_sanity_p() -> None:
67
roundtrip(im.convert("P"))