Skip to content

Commit

Permalink
Merge pull request #7302 from radarhere/png_i16
Browse files Browse the repository at this point in the history
Allow saving I;16B images as PNG
  • Loading branch information
radarhere authored Oct 6, 2023
2 parents 1e7dcd3 + 2db354a commit 2d9c4e6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Tests/test_file_png.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ def test_sanity(self, tmp_path):
assert im.format == "PNG"
assert im.get_format_mimetype() == "image/png"

for mode in ["1", "L", "P", "RGB", "I", "I;16"]:
for mode in ["1", "L", "P", "RGB", "I", "I;16", "I;16B"]:
im = hopper(mode)
im.save(test_file)
with Image.open(test_file) as reloaded:
if mode == "I;16":
if mode in ("I;16", "I;16B"):
reloaded = reloaded.convert(mode)
assert_image_equal(reloaded, im)

Expand Down
1 change: 1 addition & 0 deletions src/PIL/PngImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,7 @@ def getxmp(self):
"LA": ("LA", b"\x08\x04"),
"I": ("I;16B", b"\x10\x00"),
"I;16": ("I;16B", b"\x10\x00"),
"I;16B": ("I;16B", b"\x10\x00"),
"P;1": ("P;1", b"\x01\x03"),
"P;2": ("P;2", b"\x02\x03"),
"P;4": ("P;4", b"\x04\x03"),
Expand Down

0 comments on commit 2d9c4e6

Please sign in to comment.