diff --git a/PIL/Image.py b/PIL/Image.py index db26b9f20..b2111c97c 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1947,6 +1947,9 @@ class Image(object): containing a copy of one of the original bands (red, green, blue). + If you need only one band, :py:meth:`~PIL.Image.Image.getchannel` + method can be more convinient and faster. + :returns: A tuple containing bands. """ @@ -1964,9 +1967,11 @@ class Image(object): Returns an image contained single channel of the source image. :param channel: What channel to return. Could be index - (0 for "R" channel of "RGB") or channel name - ("A" for alpha channel of "RGBA"). + (0 for "R" channel of "RGB") or channel name + ("A" for alpha channel of "RGBA"). :returns: An image in "L" mode. + + .. versionadded:: 4.3.0 """ self.load() diff --git a/docs/reference/Image.rst b/docs/reference/Image.rst index e867494b2..8977a4332 100644 --- a/docs/reference/Image.rst +++ b/docs/reference/Image.rst @@ -146,6 +146,7 @@ ITU-R 709, using the D65 luminant) to the CIE XYZ color space: .. automethod:: PIL.Image.Image.seek .. automethod:: PIL.Image.Image.show .. automethod:: PIL.Image.Image.split +.. automethod:: PIL.Image.Image.getchannel .. automethod:: PIL.Image.Image.tell .. automethod:: PIL.Image.Image.thumbnail .. automethod:: PIL.Image.Image.tobitmap diff --git a/docs/releasenotes/4.3.0.rst b/docs/releasenotes/4.3.0.rst new file mode 100644 index 000000000..a356a67a2 --- /dev/null +++ b/docs/releasenotes/4.3.0.rst @@ -0,0 +1,9 @@ +4.3.0 +----- + +Get One Channel From Image +============================ + +New method :py:meth:`PIL.Image.Image.getchannel` added. +It returns single channel by index or name. For example, +``image.getchannel("A")`` will return alpha channel as seperate image. diff --git a/docs/releasenotes/index.rst b/docs/releasenotes/index.rst index 27b12face..4ea95f659 100644 --- a/docs/releasenotes/index.rst +++ b/docs/releasenotes/index.rst @@ -6,6 +6,7 @@ Release Notes .. toctree:: :maxdepth: 2 + 4.3.0 4.2.1 4.2.0 4.1.1 @@ -21,5 +22,3 @@ Release Notes 3.0.0 2.8.0 2.7.0 - -