Workaround 16 bit image to numpy array conversion bug in PIL

This commit is contained in:
cgohlke
2011-12-05 15:57:09 -08:00
parent b7d88b9691
commit 9b19bd9afc
+5 -1
View File
@@ -20,7 +20,11 @@ def imread(fname, dtype=None):
else:
im = im.convert('RGB')
if 'A' in im.mode:
if im.mode == 'I;16':
shape = im.size
im = np.fromstring(im.tostring(), dtype=np.uint16)
im.shape = shape[::-1]
elif 'A' in im.mode:
im = im.convert('RGBA')
return np.array(im, dtype=dtype)