Skip to content

Commit 925fe51

Browse files
committed
Support saving I;16L images
1 parent 4ba97d1 commit 925fe51

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

Tests/test_file_tiff.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,10 @@ def test_sanity(self, tmp_path: Path) -> None:
4949
assert im.size == (128, 128)
5050
assert im.format == "TIFF"
5151

52-
hopper("1").save(filename)
53-
with Image.open(filename):
54-
pass
55-
56-
hopper("L").save(filename)
57-
with Image.open(filename):
58-
pass
59-
60-
hopper("P").save(filename)
61-
with Image.open(filename):
62-
pass
63-
64-
hopper("RGB").save(filename)
65-
with Image.open(filename):
66-
pass
67-
68-
hopper("I").save(filename)
69-
with Image.open(filename):
70-
pass
52+
for mode in ("1", "L", "P", "RGB", "I", "I;16", "I;16L"):
53+
hopper(mode).save(filename)
54+
with Image.open(filename):
55+
pass
7156

7257
@pytest.mark.skipif(is_pypy(), reason="Requires CPython")
7358
def test_unclosed_file(self) -> None:

src/PIL/TiffImagePlugin.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,7 @@ def _setup(self) -> None:
16801680
"PA": ("PA", II, 3, 1, (8, 8), 2),
16811681
"I": ("I;32S", II, 1, 2, (32,), None),
16821682
"I;16": ("I;16", II, 1, 1, (16,), None),
1683+
"I;16L": ("I;16L", II, 1, 1, (16,), None),
16831684
"F": ("F;32F", II, 1, 3, (32,), None),
16841685
"RGB": ("RGB", II, 2, 1, (8, 8, 8), None),
16851686
"RGBX": ("RGBX", II, 2, 1, (8, 8, 8, 8), 0),
@@ -1963,7 +1964,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
19631964
# we're storing image byte order. So, if the rawmode
19641965
# contains I;16, we need to convert from native to image
19651966
# byte order.
1966-
if im.mode in ("I;16B", "I;16"):
1967+
if im.mode in ("I;16", "I;16B", "I;16L"):
19671968
rawmode = "I;16N"
19681969

19691970
# Pass tags as sorted list so that the tags are set in a fixed order.

0 commit comments

Comments
 (0)