Move _repr_png_ closer to the top.
This commit is contained in:
parent
c427d60030
commit
bd86367606
1 changed files with 8 additions and 6 deletions
|
|
@ -7,13 +7,20 @@ from skimage.color import rgb2gray
|
|||
from .utils import cached_property
|
||||
|
||||
|
||||
class Image(object):
|
||||
class Image(IPythonImageMixin):
|
||||
"""Basic image class."""
|
||||
|
||||
def __init__(self, data):
|
||||
self._data = data
|
||||
|
||||
def __getitem__(self, key):
|
||||
return type(self)(self._data.__getitem__(key))
|
||||
|
||||
def _repr_png_(self):
|
||||
buf = BytesIO()
|
||||
imsave(buf, self._data)
|
||||
return buf.getvalue()
|
||||
|
||||
@classmethod
|
||||
def fromfile(cls, filename):
|
||||
return cls(imread(filename))
|
||||
|
|
@ -30,11 +37,6 @@ class Image(object):
|
|||
def T(self):
|
||||
return type(self)(self._data.swapaxes(0, 1))
|
||||
|
||||
def _repr_png_(self):
|
||||
buf = BytesIO()
|
||||
imsave(buf, self._data)
|
||||
return buf.getvalue()
|
||||
|
||||
@property
|
||||
def height(self):
|
||||
return self._data.shape[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue