|
8 | 8 |
|
9 | 9 | from PIL import Image, ImageFile, WmfImagePlugin |
10 | 10 |
|
11 | | -from .helper import assert_image_similar_tofile, hopper |
| 11 | +from .helper import assert_image_equal_tofile, assert_image_similar_tofile, hopper |
12 | 12 |
|
13 | 13 |
|
14 | 14 | def test_load_raw() -> None: |
@@ -44,6 +44,15 @@ def test_load_zero_inch() -> None: |
44 | 44 | pass |
45 | 45 |
|
46 | 46 |
|
| 47 | +def test_render() -> None: |
| 48 | + with open("Tests/images/drawing.emf", "rb") as fp: |
| 49 | + data = fp.read() |
| 50 | + b = BytesIO(data[:808] + b"\x00" + data[809:]) |
| 51 | + with Image.open(b) as im: |
| 52 | + if hasattr(Image.core, "drawwmf"): |
| 53 | + assert_image_equal_tofile(im, "Tests/images/drawing.emf") |
| 54 | + |
| 55 | + |
47 | 56 | def test_register_handler(tmp_path: Path) -> None: |
48 | 57 | class TestHandler(ImageFile.StubHandler): |
49 | 58 | methodCalled = False |
@@ -88,6 +97,20 @@ def test_load_set_dpi() -> None: |
88 | 97 |
|
89 | 98 | assert_image_similar_tofile(im, "Tests/images/drawing_wmf_ref_144.png", 2.1) |
90 | 99 |
|
| 100 | + with Image.open("Tests/images/drawing.emf") as im: |
| 101 | + assert im.size == (1625, 1625) |
| 102 | + |
| 103 | + if not hasattr(Image.core, "drawwmf"): |
| 104 | + return |
| 105 | + im.load(im.info["dpi"]) |
| 106 | + assert im.size == (1625, 1625) |
| 107 | + |
| 108 | + with Image.open("Tests/images/drawing.emf") as im: |
| 109 | + im.load((72, 144)) |
| 110 | + assert im.size == (82, 164) |
| 111 | + |
| 112 | + assert_image_equal_tofile(im, "Tests/images/drawing_emf_ref_72_144.png") |
| 113 | + |
91 | 114 |
|
92 | 115 | @pytest.mark.parametrize("ext", (".wmf", ".emf")) |
93 | 116 | def test_save(ext: str, tmp_path: Path) -> None: |
|
0 commit comments