Skip to content

Commit 9308f11

Browse files
authored
Merge pull request #8231 from radarhere/ppm_i16
2 parents e2c1357 + 8e730e1 commit 9308f11

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Tests/test_file_ppm.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def test_16bit_pgm_write(tmp_path: Path) -> None:
9595
with Image.open("Tests/images/16_bit_binary.pgm") as im:
9696
filename = str(tmp_path / "temp.pgm")
9797
im.save(filename, "PPM")
98+
assert_image_equal_tofile(im, filename)
9899

100+
im.convert("I;16").save(filename, "PPM")
99101
assert_image_equal_tofile(im, filename)
100102

101103

src/PIL/PpmImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ def _save(im: Image.Image, fp: IO[bytes], filename: str | bytes) -> None:
333333
rawmode, head = "1;I", b"P4"
334334
elif im.mode == "L":
335335
rawmode, head = "L", b"P5"
336-
elif im.mode == "I":
336+
elif im.mode in ("I", "I;16"):
337337
rawmode, head = "I;16B", b"P5"
338338
elif im.mode in ("RGB", "RGBA"):
339339
rawmode, head = "RGB", b"P6"

0 commit comments

Comments
 (0)