mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Corrects fromarray() datatype mapping for integer datatypes.
Currently failing for int16LE as of this commit.
This commit is contained in:
parent
7fb24e8af0
commit
7d5856bdf7
12
PIL/Image.py
12
PIL/Image.py
|
@ -2210,10 +2210,14 @@ _fromarray_typemap = {
|
|||
# ((1, 1), "|b1"): ("1", "1"), # broken
|
||||
((1, 1), "|u1"): ("L", "L"),
|
||||
((1, 1), "|i1"): ("I", "I;8"),
|
||||
((1, 1), "<i2"): ("I", "I;16"),
|
||||
((1, 1), ">i2"): ("I", "I;16B"),
|
||||
((1, 1), "<i4"): ("I", "I;32"),
|
||||
((1, 1), ">i4"): ("I", "I;32B"),
|
||||
((1, 1), "<u2"): ("I", "I;16"),
|
||||
((1, 1), ">u2"): ("I", "I;16B"),
|
||||
((1, 1), "<i2"): ("I", "I;16S"),
|
||||
((1, 1), ">i2"): ("I", "I;16BS"),
|
||||
((1, 1), "<u4"): ("I", "I;32"),
|
||||
((1, 1), ">u4"): ("I", "I;32B"),
|
||||
((1, 1), "<i4"): ("I", "I;32S"),
|
||||
((1, 1), ">i4"): ("I", "I;32BS"),
|
||||
((1, 1), "<f4"): ("F", "F;32F"),
|
||||
((1, 1), ">f4"): ("F", "F;32BF"),
|
||||
((1, 1), "<f8"): ("F", "F;64F"),
|
||||
|
|
|
@ -55,19 +55,28 @@ class TestNumpy(PillowTestCase):
|
|||
self.assert_image(to_image(numpy.int8), "I", TestNumpy.TEST_IMAGE_SIZE)
|
||||
|
||||
# Check non-fixed-size integer types
|
||||
self.assertRaises(TypeError, lambda: to_image(numpy.uint))
|
||||
self.assert_image(to_image(numpy.uint), "I", TestNumpy.TEST_IMAGE_SIZE)
|
||||
self.assert_image(to_image(numpy.int), "I", TestNumpy.TEST_IMAGE_SIZE)
|
||||
|
||||
# Check 16-bit integer formats
|
||||
if Image._ENDIAN == '<':
|
||||
self.assert_image(to_image(numpy.uint16), "I;16L", TestNumpy.TEST_IMAGE_SIZE)
|
||||
self.assert_image(to_image(numpy.uint16), "I;16", TestNumpy.TEST_IMAGE_SIZE)
|
||||
else:
|
||||
self.assert_image(to_image(numpy.uint16), "I;16B", TestNumpy.TEST_IMAGE_SIZE)
|
||||
self.assertRaises(TypeError, lambda: to_image(numpy.int16))
|
||||
if Image._ENDIAN == '<':
|
||||
self.assert_image(to_image(numpy.int16), "I;16S", TestNumpy.TEST_IMAGE_SIZE)
|
||||
else:
|
||||
self.assert_image(to_image(numpy.int16), "I;16BS", TestNumpy.TEST_IMAGE_SIZE)
|
||||
|
||||
# Check 32-bit integer formats
|
||||
self.assertRaises(TypeError, lambda: to_image(numpy.uint32))
|
||||
self.assert_image(to_image(numpy.int32), "I", TestNumpy.TEST_IMAGE_SIZE)
|
||||
if Image._ENDIAN == '<':
|
||||
self.assert_image(to_image(numpy.uint32), "I;32", TestNumpy.TEST_IMAGE_SIZE)
|
||||
else:
|
||||
self.assert_image(to_image(numpy.uint32), "I;32B", TestNumpy.TEST_IMAGE_SIZE)
|
||||
if Image._ENDIAN == '<':
|
||||
self.assert_image(to_image(numpy.int32), "I;32S", TestNumpy.TEST_IMAGE_SIZE)
|
||||
else:
|
||||
self.assert_image(to_image(numpy.int32), "I;32BS", TestNumpy.TEST_IMAGE_SIZE)
|
||||
|
||||
# Check 64-bit integer formats
|
||||
self.assertRaises(TypeError, lambda: to_image(numpy.uint64))
|
||||
|
|
Loading…
Reference in New Issue
Block a user