Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dddc262

Browse files
committed
Fix compatibility with older version of PIL
1 parent 791c4d5 commit dddc262

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,10 @@ def pil_to_array(pilImage):
13131313
"""
13141314
def toarray(im, dtype=np.uint8):
13151315
"""Teturn a 1D array of dtype."""
1316-
x_str = im.tobytes('raw', im.mode)
1316+
if hasattr(im, 'tobytes'):
1317+
x_str = im.tobytes('raw', im.mode)
1318+
else:
1319+
x_str = im.tostring('raw', im.mode)
13171320
x = np.fromstring(x_str, dtype)
13181321
return x
13191322

0 commit comments

Comments
 (0)