Python Imaging Library (Fork)
Go to file
Matthew Treinish 6d440ac995
Handle exceptions in _repr_jpeg_ and _repr_png_
In 10.0.0 a _repr_jpeg_ implementation was added to the Image object to
enable the use of display_jpeg() in IPython environments. However, in
some cases the implementation of this method could result in an
exception being raised while trying to generate the jpeg data. The best
example is if the image data is in an RGBA format as a result of the
object being created by opening a PNG file. In this case trying to save
the Image object as a jpeg will error because the jpeg format can't
represent the transparency in the alpha channel. This results in an
exception being raised in the IPython/Jupyter context when outputing the
image object. However, in cases like this IPython allows the repr
methods to return None to indicate there is no representation in that
format available. [1] This commit updates the _repr_png_ and _repr_jpeg_
methods to catch any exception that might be raised while trying to
generate the image data. If an exception is raised we treat that as not
being able to generate image data in that format and return None
instead.

Related to #7259

[1] https://ipython.readthedocs.io/en/stable/config/integrating.html#custom-methods
2023-07-06 08:42:37 -04:00
_custom_build Do not import internal class 2023-06-14 15:46:24 +10:00
.ci Do not test PyQt6 on Python 3.12 2023-05-27 10:28:38 +10:00
.github Merge branch 'main' into add-pyproject.toml 2023-06-28 17:44:08 +10:00
depends Updated libwebp to 1.3.1 2023-06-29 15:11:16 +10:00
docs Updated macOS tested Pillow versions 2023-07-06 13:22:50 +10:00
src Handle exceptions in _repr_jpeg_ and _repr_png_ 2023-07-06 08:42:37 -04:00
Tests Updated libjpeg shared library name 2023-07-04 22:39:41 +10:00
winbuild Updated libjpeg-turbo to 3.0.0 2023-07-04 08:29:17 +10:00
.appveyor.yml Merge branch 'main' into add-pyproject.toml 2023-06-28 17:44:08 +10:00
.clang-format Adjust clang-format style 2021-01-03 14:16:42 +11:00
.coveragerc Removed unnecessary line 2020-01-03 16:40:31 +11:00
.editorconfig Removed duplicate config 2023-06-01 22:53:07 +10:00
.gitattributes Set EPS test files as binary 2018-12-29 21:53:07 -08:00
.gitignore Updated test images origin 2023-02-08 10:01:10 +11:00
.pre-commit-config.yaml [pre-commit.ci] pre-commit autoupdate 2023-07-03 19:29:28 +00:00
.readthedocs.yml Build only PDF in addition to default html 2023-05-15 15:47:30 +03:00
CHANGES.rst 10.0.0 version bump 2023-07-01 22:08:11 +10:00
codecov.yml Restored 32-bit support 2023-06-27 14:43:58 +10:00
conftest.py Declare helper as a pytest plugin so asserts aren't ignored with PYTHONOPTIMIZE 2020-02-02 12:26:01 +02:00
LICENSE Update HPND wording in LICENSE file 2023-02-09 23:23:29 +01:00
Makefile Removed inplace target 2023-05-20 15:38:53 +10:00
MANIFEST.in Use --config-settings instead of deprecated --global-option 2023-05-20 15:38:36 +10:00
pyproject.toml Remove redundant wheel dep from pyproject.toml 2023-07-02 04:13:02 +02:00
README.md Alex Clark -> Jeffrey A. Clark (Alex) 2023-01-14 12:36:22 -05:00
RELEASING.md Clarify command should be run from main repo 2023-04-10 15:49:18 +03:00
selftest.py Remove redundant parentheses 2022-04-10 23:39:54 +03:00
setup.cfg Drop support for soon-EOL Python 3.7 2023-04-01 15:58:08 +03:00
setup.py Merge branch 'main' into add-pyproject.toml 2023-06-28 17:44:08 +10:00
tox.ini Removed inplace target 2023-05-20 15:38:53 +10:00

Pillow logo

Pillow

Python Imaging Library (Fork)

Pillow is the friendly PIL fork by Jeffrey A. Clark (Alex) and contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors. As of 2019, Pillow development is supported by Tidelift.

docs Documentation Status
tests GitHub Actions build status (Lint) GitHub Actions build status (Test Linux and macOS) GitHub Actions build status (Test Windows) GitHub Actions build status (Test MinGW) GitHub Actions build status (Test Cygwin) GitHub Actions build status (Test Docker) AppVeyor CI build status (Windows) GitHub Actions wheels build status (Wheels) Travis CI wheels build status (aarch64) Code coverage Fuzzing Status
package Zenodo Tidelift Newest PyPI version Number of PyPI downloads OpenSSF Best Practices
social Join the chat at https://gitter.im/python-pillow/Pillow Follow on https://twitter.com/PythonPillow Follow on https://fosstodon.org/@pillow

Overview

The Python Imaging Library adds image processing capabilities to your Python interpreter.

This library provides extensive file format support, an efficient internal representation, and fairly powerful image processing capabilities.

The core image library is designed for fast access to data stored in a few basic pixel formats. It should provide a solid foundation for a general image processing tool.

More Information

Report a Vulnerability

To report a security vulnerability, please follow the procedure described in the Tidelift security policy.