diff --git a/Tests/images/uint16_2_4660.tif b/Tests/images/uint16_2_4660.tif new file mode 100644 index 000000000..188ff2af7 Binary files /dev/null and b/Tests/images/uint16_2_4660.tif differ diff --git a/Tests/images/uint16_3_4660.tif b/Tests/images/uint16_3_4660.tif new file mode 100644 index 000000000..3c2bc8658 Binary files /dev/null and b/Tests/images/uint16_3_4660.tif differ diff --git a/Tests/images/uint16_4_4660.tif b/Tests/images/uint16_4_4660.tif new file mode 100644 index 000000000..ae8252d78 Binary files /dev/null and b/Tests/images/uint16_4_4660.tif differ diff --git a/Tests/images/uint16_5_4660.tif b/Tests/images/uint16_5_4660.tif new file mode 100644 index 000000000..df92724c3 Binary files /dev/null and b/Tests/images/uint16_5_4660.tif differ diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 8821fb46a..8a54f0756 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -874,6 +874,19 @@ class TestFileTiff: with Image.open(test_file): pass + def test_open_tiff_uint16_multiband(self): + """Test opening multiband TIFFs and reading all channels.""" + base_value = 4660 + for i in range(2, 6): + infile = f"Tests/images/uint16_{i}_{base_value}.tif" + im = Image.open(infile) + im.load() + pixel = [base_value + j for j in range(0, i)] + actual_pixel = im.getpixel((0, 0)) + if isinstance(actual_pixel, int): + actual_pixel = [actual_pixel] + assert actual_pixel == pixel + @pytest.mark.skipif(not is_win32(), reason="Windows only") class TestFileTiffW32: diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py index 54faa59c5..e70f12526 100644 --- a/src/PIL/TiffImagePlugin.py +++ b/src/PIL/TiffImagePlugin.py @@ -182,6 +182,43 @@ OPEN_INFO = { (II, 1, (1,), 1, (12,), ()): ("I;16", "I;12"), (II, 0, (1,), 1, (16,), ()): ("I;16", "I;16"), (II, 1, (1,), 1, (16,), ()): ("I;16", "I;16"), + (II, 1, (1,), 1, (16, 16), (0,)): ("I;16", "I;16"), + ( + II, + 1, + (1,), + 1, + (16, 16, 16), + ( + 0, + 0, + ), + ): ("I;16", "I;16"), + ( + II, + 1, + (1,), + 1, + (16, 16, 16, 16), + ( + 0, + 0, + 0, + ), + ): ("I;16", "I;16"), + ( + II, + 1, + (1,), + 1, + (16, 16, 16, 16, 16), + ( + 0, + 0, + 0, + 0, + ), + ): ("I;16", "I;16"), (MM, 1, (1,), 1, (16,), ()): ("I;16B", "I;16B"), (II, 1, (1,), 2, (16,), ()): ("I;16", "I;16R"), (II, 1, (2,), 1, (16,), ()): ("I", "I;16S"),