Skip to content

Commit

Permalink
Merge pull request #7242 from radarhere/repr_png
Browse files Browse the repository at this point in the history
Prioritise speed in _repr_png_
  • Loading branch information
hugovk committed Jun 30, 2023
2 parents 1174a9e + 0740499 commit bd795d7
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit bd795d7

Please sign in to comment.