diff --git a/Tests/images/16_bit_noise.tif b/Tests/images/16_bit_noise.tif new file mode 100644 index 000000000..19180638e Binary files /dev/null and b/Tests/images/16_bit_noise.tif differ diff --git a/Tests/test_image_getextrema.py b/Tests/test_image_getextrema.py index 0b0c31b86..9783141a3 100644 --- a/Tests/test_image_getextrema.py +++ b/Tests/test_image_getextrema.py @@ -1,3 +1,4 @@ +from PIL import Image from helper import unittest, PillowTestCase, hopper @@ -19,6 +20,13 @@ class TestImageGetExtrema(PillowTestCase): extrema("RGBA"), ((0, 255), (0, 255), (0, 255), (255, 255))) self.assertEqual( extrema("CMYK"), (((0, 255), (0, 255), (0, 255), (0, 0)))) + self.assertEqual(extrema("I;16"), (0, 255)) + + def test_true_16(self): + im = Image.open("Tests/images/16_bit_noise.tif") + self.assertEqual(im.mode, 'I;16') + extrema = im.getextrema() + self.assertEqual(extrema, (106, 285)) if __name__ == '__main__': diff --git a/src/_imaging.c b/src/_imaging.c index 3acbdb01c..9620a0691 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -1998,6 +1998,7 @@ _getextrema(ImagingObject* self, PyObject* args) UINT8 u[2]; INT32 i[2]; FLOAT32 f[2]; + UINT16 s[2]; } extrema; int status; @@ -2013,6 +2014,10 @@ _getextrema(ImagingObject* self, PyObject* args) return Py_BuildValue("ii", extrema.i[0], extrema.i[1]); case IMAGING_TYPE_FLOAT32: return Py_BuildValue("dd", extrema.f[0], extrema.f[1]); + case IMAGING_TYPE_SPECIAL: + if (strcmp(self->image->mode, "I;16") == 0) { + return Py_BuildValue("HH", extrema.s[0], extrema.s[1]); + } } Py_INCREF(Py_None);