From 07404991512d370723ef835b0954d2fcb4eee883 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Fri, 30 Jun 2023 09:05:59 +1000 Subject: [PATCH] Prioritise speed in _repr_png_ --- src/PIL/Image.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 0464513fd..08bb5615b 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -632,7 +632,7 @@ class Image: ) ) - def _repr_image(self, image_format): + def _repr_image(self, image_format, **kwargs): """Helper function for iPython display hook. :param image_format: Image format. @@ -640,7 +640,7 @@ class Image: """ 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 @@ -651,7 +651,7 @@ class Image: :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.