mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 02:16:19 +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
|
raise ValueError("Could not save to PNG for display") from e
|
||||||
return b.getvalue()
|
return b.getvalue()
|
||||||
|
|
||||||
|
class _ArrayData:
|
||||||
|
def __init__(self, new):
|
||||||
|
self.__array_interface__ = new
|
||||||
|
|
||||||
def __array__(self, dtype=None):
|
def __array__(self, dtype=None):
|
||||||
# numpy array interface support
|
# numpy array interface support
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -672,10 +676,7 @@ class Image:
|
||||||
else:
|
else:
|
||||||
new["data"] = self.tobytes()
|
new["data"] = self.tobytes()
|
||||||
|
|
||||||
class ArrayData:
|
return np.array(self._ArrayData(new), dtype)
|
||||||
__array_interface__ = new
|
|
||||||
|
|
||||||
return np.array(ArrayData(), dtype)
|
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
return [self.info, self.mode, self.size, self.getpalette(), self.tobytes()]
|
return [self.info, self.mode, self.size, self.getpalette(), self.tobytes()]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user