Merge pull request #886 from stefanv/bug/pil-fromstring_to_bytes

Use frombytes instead of fromstring on PIL images
This commit is contained in:
Juan Nunez-Iglesias
2014-02-12 22:29:31 +11:00
+7 -1
View File
@@ -109,7 +109,13 @@ def imsave(fname, arr, format_str=None):
if not isinstance(fname, string_types) and format_str is None:
format_str = "PNG"
img = Image.fromstring(mode, (arr.shape[1], arr.shape[0]), arr.tostring())
try:
img = Image.frombytes(mode, (arr.shape[1], arr.shape[0]),
arr.tostring())
except AttributeError:
img = Image.fromstring(mode, (arr.shape[1], arr.shape[0]),
arr.tostring())
img.save(fname, format=format_str)