Fix Image.fromarray with NumPy arrays

Image.fromarray attempts to call a method called `tobytes()` on the passed in object, but NumPy arrays don't have a `tobytes()` method, they have a `tostring()` method. (See http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.tostring.html).

I think this was changed accidentally in a Python 3 compatibility update in which this call was confused with the `tobytes` and `frombytes` methods of Image objects.
This commit is contained in:
Matt Davis 2013-05-21 18:35:11 -03:00
parent 1c3ff8857a
commit 1082173030

View File

@ -1944,7 +1944,7 @@ def fromarray(obj, mode=None):
size = shape[1], shape[0]
if strides is not None:
obj = obj.tobytes()
obj = obj.tostring()
return frombuffer(mode, size, obj, "raw", rawmode, 0, 1)