-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Added _repr_jpeg_() for IPython display_jpeg #7135
Conversation
Signed-off-by: Ishant Mrinal Haloi <mrinal.haloi11@gmail.com>
If I understand correctly, this is not just for passing an image object directly to IPython, like in #1090 (comment) from PIL import Image
im = Image.new("RGB", (512, 512), "blue")
im and not just for |
Yes this is |
_repr_jpg_
for ipython display_repr_jpg_
for IPython display
src/PIL/Image.py
Outdated
@@ -633,19 +633,36 @@ def _repr_pretty_(self, p, cycle): | |||
) | |||
) | |||
|
|||
def _repr_png_(self): | |||
def _repr_image(self, format): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change format
to something that doesn't shadow a builtin?
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
Only assert image is similar
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
_repr_jpg_
for IPython display_repr_jpeg_
for IPython display
Co-authored-by: Ondrej Baranovič <3819630+nulano@users.noreply.github.com> Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please could you also mention this in the release notes?
https://github.com/python-pillow/Pillow/blob/main/docs/releasenotes/10.0.0.rst
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Added release notes
Release notes have now been added - https://pillow--7135.org.readthedocs.build/en/7135/releasenotes/10.0.0.html#support-display-jpeg-in-ipython |
_repr_jpeg_
for IPython display_repr_jpeg_
for IPython display_jpeg
_repr_jpeg_
for IPython display_jpeg
I'm wondering what the purpose of this change is. I'm interested to know if it's mainly to support calling If so, this seems to be having unintended consequences as I'm now getting both a PNG and JPEG encoded image saved in each cell. For example, a cell I just created includes:
which might well double resulting |
Yes. That is what the original poster was after, and that is what we have announced. Discussion of double images can continue in #7259 |
Changes proposed in this pull request:
_repr_jpg_
and_repr_jpeg_
method for ipython display (similar to currently existing_repr_png_
)