mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-13 02:36:17 +03:00
Add earlier catching of wrong channels count
This commit is contained in:
parent
bdd8dc40f6
commit
daa8e7dacd
|
@ -254,6 +254,9 @@ class TestColorLut3DFilter(PillowTestCase):
|
|||
with self.assertRaisesRegexp(ValueError, "should have a length of 3"):
|
||||
ImageFilter.Color3DLUT((2, 2, 2), [[1, 1]] * 8)
|
||||
|
||||
with self.assertRaisesRegexp(ValueError, "Only 3 or 4 output"):
|
||||
ImageFilter.Color3DLUT((2, 2, 2), [[1, 1]] * 8, channels=2)
|
||||
|
||||
def test_convert_table(self):
|
||||
lut = ImageFilter.Color3DLUT(2, [0, 1, 2] * 8)
|
||||
self.assertEqual(tuple(lut.size), (2, 2, 2))
|
||||
|
|
|
@ -326,6 +326,8 @@ class Color3DLUT(MultibandFilter):
|
|||
name = "Color 3D LUT"
|
||||
|
||||
def __init__(self, size, table, channels=3, target_mode=None, **kwargs):
|
||||
if channels not in (3, 4):
|
||||
raise ValueError("Only 3 or 4 output channels are supported")
|
||||
self.size = size = self._check_size(size)
|
||||
self.channels = channels
|
||||
self.mode = target_mode
|
||||
|
|
Loading…
Reference in New Issue
Block a user