Simplified code

This commit is contained in:
Andrew Murray 2023-07-23 16:26:42 +10:00
parent 6215cd3e0f
commit e5c94eced2

View File

@ -641,9 +641,8 @@ class Image:
b = io.BytesIO()
try:
self.save(b, image_format, **kwargs)
except Exception as e:
msg = f"Could not save to {image_format} for display"
raise ValueError(msg) from e
except Exception:
return None
return b.getvalue()
def _repr_png_(self):
@ -651,20 +650,14 @@ class Image:
:returns: PNG version of the image as bytes
"""
try:
return self._repr_image("PNG", compress_level=1)
except Exception:
return None
def _repr_jpeg_(self):
"""iPython display hook support for JPEG format.
:returns: JPEG version of the image as bytes
"""
try:
return self._repr_image("JPEG")
except Exception:
return None
@property
def __array_interface__(self):