Simplified check for number of channels

This commit is contained in:
Andrew Murray 2021-07-25 13:10:29 +10:00 committed by GitHub
parent 5593b629b9
commit 7725aa5f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1297,13 +1297,8 @@ class Image:
elif quality != 1.0: elif quality != 1.0:
self.thumbnail((quality * self.width, quality * self.height)) self.thumbnail((quality * self.width, quality * self.height))
if self.mode in ("F", "L", "I", "P"): channels = self.im.bands
channels = 1 if channels not in (1, 3, 4):
elif self.mode in ("RGB", "YCbCr", "LAB", "HSV"):
channels = 3
elif self.mode in ("RGBA", "CMYK"):
channels = 4
else:
raise ValueError("Unsupported image mode") raise ValueError("Unsupported image mode")
def euclidean(p1, p2): def euclidean(p1, p2):