mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-28 11:25:42 +08:00
Fix compatibility with PIL
This commit is contained in:
@@ -181,14 +181,14 @@ def ndarray_to_pil(arr, format_str=None):
|
||||
try:
|
||||
im.frombytes(arr.tobytes(), 'raw', mode)
|
||||
except AttributeError:
|
||||
im.frombytes(arr.tostring(), 'raw', mode)
|
||||
im.fromstring(arr.tostring(), 'raw', mode)
|
||||
|
||||
else:
|
||||
try:
|
||||
im = Image.frombytes(mode, (arr.shape[1], arr.shape[0]),
|
||||
arr.tobytes())
|
||||
except AttributeError:
|
||||
im = Image.frombytes(mode, (arr.shape[1], arr.shape[0]),
|
||||
im = Image.fromstring(mode, (arr.shape[1], arr.shape[0]),
|
||||
arr.tostring())
|
||||
return im
|
||||
|
||||
|
||||
@@ -195,7 +195,10 @@ def test_cmyk():
|
||||
fname = f.name
|
||||
f.close()
|
||||
img.save(fname)
|
||||
img.close()
|
||||
try:
|
||||
img.close()
|
||||
except AttributeError: # `close` not available on PIL
|
||||
pass
|
||||
|
||||
new = imread(fname)
|
||||
|
||||
@@ -231,4 +234,4 @@ class TestSaveTIF:
|
||||
yield self.roundtrip, dtype, x
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_module_suite()
|
||||
run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user