Merge pull request #102 from tonysyu/pil-big-endian

BUG: Fix PIL big endian regression.
This commit is contained in:
Stefan van der Walt
2011-12-13 12:57:06 -08:00
3 changed files with 9 additions and 1 deletions
Binary file not shown.
+1 -1
View File
@@ -23,7 +23,7 @@ def imread(fname, dtype=None):
im = im.convert('RGB')
elif im.mode == '1':
im = im.convert('L')
elif im.mode == 'I;16':
elif im.mode.startswith('I;16'):
shape = im.size
dtype = '>u2' if im.mode.endswith('B') else '<u2'
im = np.fromstring(im.tostring(), dtype)
+8
View File
@@ -51,6 +51,14 @@ def test_bilevel():
img = imread(os.path.join(data_dir, 'checker_bilevel.png'))
assert_array_equal(img, expected)
@skipif(not PIL_available)
def test_imread_uint16():
expected = np.load(os.path.join(data_dir, 'chessboard_GRAY_U8.npy'))
img = imread(os.path.join(data_dir, 'chessboard_GRAY_U16.tif'))
assert img.dtype == np.uint16
assert_array_almost_equal(img, expected)
class TestSave:
def roundtrip(self, dtype, x, scaling=1):
f = NamedTemporaryFile(suffix='.png')