File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -696,6 +696,12 @@ def test_rgb_lab(mode: str) -> None:
696696 assert value [:3 ] == (0 , 255 , 255 )
697697
698698
699+ def test_cmyk_lab () -> None :
700+ im = Image .new ("CMYK" , (1 , 1 ))
701+ converted_im = im .convert ("LAB" )
702+ assert converted_im .getpixel ((0 , 0 )) == (255 , 128 , 128 )
703+
704+
699705def test_deprecation () -> None :
700706 with pytest .warns (DeprecationWarning ):
701707 assert ImageCms .DESCRIPTION .strip ().startswith ("pyCMS" )
Original file line number Diff line number Diff line change @@ -1130,17 +1130,23 @@ def convert_transparency(
11301130 return new_im
11311131
11321132 if "LAB" in (self .mode , mode ):
1133- other_mode = mode if self .mode == "LAB" else self .mode
1133+ im = self
1134+ if mode == "LAB" :
1135+ if im .mode not in ("RGB" , "RGBA" , "RGBX" ):
1136+ im = im .convert ("RGBA" )
1137+ other_mode = im .mode
1138+ else :
1139+ other_mode = mode
11341140 if other_mode in ("RGB" , "RGBA" , "RGBX" ):
11351141 from . import ImageCms
11361142
11371143 srgb = ImageCms .createProfile ("sRGB" )
11381144 lab = ImageCms .createProfile ("LAB" )
1139- profiles = [lab , srgb ] if self .mode == "LAB" else [srgb , lab ]
1145+ profiles = [lab , srgb ] if im .mode == "LAB" else [srgb , lab ]
11401146 transform = ImageCms .buildTransform (
1141- profiles [0 ], profiles [1 ], self .mode , mode
1147+ profiles [0 ], profiles [1 ], im .mode , mode
11421148 )
1143- return transform .apply (self )
1149+ return transform .apply (im )
11441150
11451151 # colorspace conversion
11461152 if dither is None :
You can’t perform that action at this time.
0 commit comments