From a9c46bc288d23c95fd08ee66493cb07be074f02e Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Wed, 28 Dec 2022 10:22:10 +1100 Subject: [PATCH 1/2] Document "transparency" info key --- docs/handbook/concepts.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/handbook/concepts.rst b/docs/handbook/concepts.rst index f3fa1f2b1bb..f7bc9396b23 100644 --- a/docs/handbook/concepts.rst +++ b/docs/handbook/concepts.rst @@ -111,6 +111,18 @@ the file format handler (see the chapter on :ref:`image-file-formats`). Most handlers add properties to the :py:attr:`~PIL.Image.Image.info` attribute when loading an image, but ignore it when saving images. +Transparency +------------ + +If an image does not have an alpha band, transparency may be specified in the +:py:attr:`~PIL.Image.Image.info` attribute with a "transparency" key. + +Most of the time, the "transparency" value is a single integer, describing +which pixel value is transparent in an "1", "L", "I" or "P" mode image. +However, PNG images may have three values, one for each channel in an "RGB" +mode image, or can have a byte string for a "P" mode image, to specify the +alpha value for each palette entry. + Orientation ----------- From a4baeda9f69a7ada9b78437be10adb66c3520b75 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Thu, 29 Dec 2022 11:07:16 +1100 Subject: [PATCH 2/2] Fixed typo Co-authored-by: Hugo van Kemenade --- docs/handbook/concepts.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/handbook/concepts.rst b/docs/handbook/concepts.rst index f7bc9396b23..ed25e186508 100644 --- a/docs/handbook/concepts.rst +++ b/docs/handbook/concepts.rst @@ -118,7 +118,7 @@ If an image does not have an alpha band, transparency may be specified in the :py:attr:`~PIL.Image.Image.info` attribute with a "transparency" key. Most of the time, the "transparency" value is a single integer, describing -which pixel value is transparent in an "1", "L", "I" or "P" mode image. +which pixel value is transparent in a "1", "L", "I" or "P" mode image. However, PNG images may have three values, one for each channel in an "RGB" mode image, or can have a byte string for a "P" mode image, to specify the alpha value for each palette entry.