mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-29 17:33:08 +03:00
Simplified code
This commit is contained in:
parent
6215cd3e0f
commit
e5c94eced2
|
@ -641,9 +641,8 @@ class Image:
|
||||||
b = io.BytesIO()
|
b = io.BytesIO()
|
||||||
try:
|
try:
|
||||||
self.save(b, image_format, **kwargs)
|
self.save(b, image_format, **kwargs)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
msg = f"Could not save to {image_format} for display"
|
return None
|
||||||
raise ValueError(msg) from e
|
|
||||||
return b.getvalue()
|
return b.getvalue()
|
||||||
|
|
||||||
def _repr_png_(self):
|
def _repr_png_(self):
|
||||||
|
@ -651,20 +650,14 @@ class Image:
|
||||||
|
|
||||||
:returns: PNG version of the image as bytes
|
:returns: PNG version of the image as bytes
|
||||||
"""
|
"""
|
||||||
try:
|
return self._repr_image("PNG", compress_level=1)
|
||||||
return self._repr_image("PNG", compress_level=1)
|
|
||||||
except Exception:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _repr_jpeg_(self):
|
def _repr_jpeg_(self):
|
||||||
"""iPython display hook support for JPEG format.
|
"""iPython display hook support for JPEG format.
|
||||||
|
|
||||||
:returns: JPEG version of the image as bytes
|
:returns: JPEG version of the image as bytes
|
||||||
"""
|
"""
|
||||||
try:
|
return self._repr_image("JPEG")
|
||||||
return self._repr_image("JPEG")
|
|
||||||
except Exception:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def __array_interface__(self):
|
def __array_interface__(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user