Fix reading 16 bit big-endian images with PIL

This commit is contained in:
cgohlke
2011-12-08 11:29:46 -08:00
parent 1aec5f045b
commit c825548d23
+3 -2
View File
@@ -20,9 +20,10 @@ def imread(fname, dtype=None):
else:
im = im.convert('RGB')
if im.mode == 'I;16':
if im.mode.startswith('I;16'):
shape = im.size
im = np.fromstring(im.tostring(), dtype=np.uint16)
dtype = '>u2' if im.mode.endswith('B') else '<u2'
im = np.fromstring(im.tostring(), dtype)
im.shape = shape[::-1]
elif 'A' in im.mode:
im = im.convert('RGBA')