diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 0fca3fa5c..2653c6274 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -644,6 +644,19 @@ class Image: id(self), ) + def _repr_pretty_(self, p, cycle): + """IPython plain text display support""" + + # Same as __repr__ but without unpredicatable id(self), + # to keep Jupyter notebook `text/plain` output stable. + p.text("<%s.%s image mode=%s size=%dx%d>" % ( + self.__class__.__module__, + self.__class__.__name__, + self.mode, + self.size[0], + self.size[1], + )) + def _repr_png_(self): """iPython display hook support