Skip to content

Commit

Permalink
Merge pull request #7111 from radarhere/tiff
Browse files Browse the repository at this point in the history
Support reading signed 8-bit TIFF images
  • Loading branch information
hugovk committed May 4, 2023
2 parents 2467db4 + 9154a6b commit 1e7c77c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Binary file added Tests/images/8bit.s.tif
Binary file not shown.
6 changes: 6 additions & 0 deletions Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ def test_save_unsupported_mode(self, tmp_path):
with pytest.raises(OSError):
im.save(outfile)

def test_8bit_s(self):
with Image.open("Tests/images/8bit.s.tif") as im:
im.load()
assert im.mode == "L"
assert im.getpixel((50, 50)) == 184

def test_little_endian(self):
with Image.open("Tests/images/16bit.cropped.tif") as im:
assert im.getpixel((0, 0)) == 480
Expand Down
7 changes: 4 additions & 3 deletions docs/releasenotes/10.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ TODO
Other Changes
=============

TODO
^^^^
Support reading signed 8-bit TIFF images
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TODO
TIFF images with signed integer data, 8 bits per sample and a photometric
interpretaton of BlackIsZero can now be read.
2 changes: 2 additions & 0 deletions src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
(MM, 0, (1,), 2, (8,), ()): ("L", "L;IR"),
(II, 1, (1,), 1, (8,), ()): ("L", "L"),
(MM, 1, (1,), 1, (8,), ()): ("L", "L"),
(II, 1, (2,), 1, (8,), ()): ("L", "L"),
(MM, 1, (2,), 1, (8,), ()): ("L", "L"),
(II, 1, (1,), 2, (8,), ()): ("L", "L;R"),
(MM, 1, (1,), 2, (8,), ()): ("L", "L;R"),
(II, 1, (1,), 1, (12,), ()): ("I;16", "I;12"),
Expand Down

0 comments on commit 1e7c77c

Please sign in to comment.