mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-26 07:04:45 +03:00
Typing: Image.getchannel
This commit is contained in:
parent
4b47177634
commit
e220e00386
|
@ -2128,14 +2128,18 @@ class Image(object):
|
||||||
"""
|
"""
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
channel_int = 0
|
||||||
|
|
||||||
if isStringType(channel):
|
if isStringType(channel):
|
||||||
try:
|
try:
|
||||||
channel = self.getbands().index(channel)
|
channel_int = self.getbands().index(channel)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
'The image has no channel "{}"'.format(channel))
|
'The image has no channel "{}"'.format(channel))
|
||||||
|
else:
|
||||||
|
channel_int = channel # type: ignore
|
||||||
|
|
||||||
return self._new(self.im.getband(channel))
|
return self._new(self.im.getband(channel_int))
|
||||||
|
|
||||||
def tell(self):
|
def tell(self):
|
||||||
# type: () -> int
|
# type: () -> int
|
||||||
|
|
Loading…
Reference in New Issue
Block a user