mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 21:24:31 +03:00
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:
parent
1c3ff8857a
commit
1082173030
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user