mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 18:06:18 +03:00
Merge pull request #5844 from radarhere/numpy_array
This commit is contained in:
commit
059503b9c0
|
@ -656,6 +656,10 @@ class Image:
|
|||
raise ValueError("Could not save to PNG for display") from e
|
||||
return b.getvalue()
|
||||
|
||||
class _ArrayData:
|
||||
def __init__(self, new):
|
||||
self.__array_interface__ = new
|
||||
|
||||
def __array__(self, dtype=None):
|
||||
# numpy array interface support
|
||||
import numpy as np
|
||||
|
@ -672,10 +676,7 @@ class Image:
|
|||
else:
|
||||
new["data"] = self.tobytes()
|
||||
|
||||
class ArrayData:
|
||||
__array_interface__ = new
|
||||
|
||||
return np.array(ArrayData(), dtype)
|
||||
return np.array(self._ArrayData(new), dtype)
|
||||
|
||||
def __getstate__(self):
|
||||
return [self.info, self.mode, self.size, self.getpalette(), self.tobytes()]
|
||||
|
|
Loading…
Reference in New Issue
Block a user