From 4087479464d6f41390b0f33be085c805a4bb56a2 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Sat, 19 Sep 2015 10:12:00 +1000 Subject: [PATCH 1/3] Added test image --- Tests/images/16bit.s.tif | Bin 0 -> 334 bytes Tests/test_file_tiff.py | 5 +++++ 2 files changed, 5 insertions(+) create mode 100644 Tests/images/16bit.s.tif diff --git a/Tests/images/16bit.s.tif b/Tests/images/16bit.s.tif new file mode 100644 index 0000000000000000000000000000000000000000..f36e68d610b3787efaa0778b4f7d07538a7094f6 GIT binary patch literal 334 zcmebD)MB{6z`*do9!Ow-p(o14z`)4NzzFmSkj21=#AbrB1%TqrP&P;%8xmWPkp--m a11K(vBrXmWKLHe%K@ty!vYCM5AOHZ4HWFz7 literal 0 HcmV?d00001 diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 2a9132d48..4c6ae4af3 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -198,6 +198,11 @@ class TestFileTiff(PillowTestCase): self.assertEqual(b[0], b'\x01') self.assertEqual(b[1], b'\xe0') + def test_16bit_s(self): + im = Image.open('Tests/images/16bit.s.tif') + im.load() + self.assertEqual(im.mode, 'I;16S') + def test_12bit_rawmode(self): """ Are we generating the same interpretation of the image as Imagemagick is? """ From 60cbe9fe44486a01fa3bf21d0a0724b117bb2107 Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Wed, 20 Sep 2017 09:26:14 +0000 Subject: [PATCH 2/3] I;16(B)S and I;32BS aren't modes, they're rawmodes --- PIL/TiffImagePlugin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PIL/TiffImagePlugin.py b/PIL/TiffImagePlugin.py index bd66f4a7a..297913afe 100644 --- a/PIL/TiffImagePlugin.py +++ b/PIL/TiffImagePlugin.py @@ -172,14 +172,14 @@ OPEN_INFO = { (II, 1, (1,), 1, (16,), ()): ("I;16", "I;16"), (MM, 1, (1,), 1, (16,), ()): ("I;16B", "I;16B"), - (II, 1, (2,), 1, (16,), ()): ("I;16S", "I;16S"), - (MM, 1, (2,), 1, (16,), ()): ("I;16BS", "I;16BS"), + (II, 1, (2,), 1, (16,), ()): ("I", "I;16S"), + (MM, 1, (2,), 1, (16,), ()): ("I", "I;16BS"), (II, 0, (3,), 1, (32,), ()): ("F", "F;32F"), (MM, 0, (3,), 1, (32,), ()): ("F", "F;32BF"), (II, 1, (1,), 1, (32,), ()): ("I", "I;32N"), (II, 1, (2,), 1, (32,), ()): ("I", "I;32S"), - (MM, 1, (2,), 1, (32,), ()): ("I;32BS", "I;32BS"), + (MM, 1, (2,), 1, (32,), ()): ("I", "I;32BS"), (II, 1, (3,), 1, (32,), ()): ("F", "F;32F"), (MM, 1, (3,), 1, (32,), ()): ("F", "F;32BF"), From a89c4e455d61af6524eff14437031f830522eedc Mon Sep 17 00:00:00 2001 From: Eric Soroos Date: Wed, 20 Sep 2017 09:26:40 +0000 Subject: [PATCH 3/3] Target mode is I, check pixels --- Tests/test_file_tiff.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/test_file_tiff.py b/Tests/test_file_tiff.py index 4c6ae4af3..115a0e765 100644 --- a/Tests/test_file_tiff.py +++ b/Tests/test_file_tiff.py @@ -201,7 +201,9 @@ class TestFileTiff(PillowTestCase): def test_16bit_s(self): im = Image.open('Tests/images/16bit.s.tif') im.load() - self.assertEqual(im.mode, 'I;16S') + self.assertEqual(im.mode, 'I') + self.assertEqual(im.getpixel((0,0)),32767) + self.assertEqual(im.getpixel((0,1)),0) def test_12bit_rawmode(self): """ Are we generating the same interpretation