Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prioritise speed in _repr_png_ #7242

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,15 +632,15 @@ def _repr_pretty_(self, p, cycle):
)
)

def _repr_image(self, image_format):
def _repr_image(self, image_format, **kwargs):
"""Helper function for iPython display hook.

:param image_format: Image format.
:returns: image as bytes, saved into the given format.
"""
b = io.BytesIO()
try:
self.save(b, image_format)
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
Expand All @@ -651,7 +651,7 @@ def _repr_png_(self):

:returns: PNG version of the image as bytes
"""
return self._repr_image("PNG")
return self._repr_image("PNG", compress_level=1)

def _repr_jpeg_(self):
"""iPython display hook support for JPEG format.
Expand Down