@@ -388,6 +388,37 @@ def test_alpha_composite(self) -> None:
388388 assert img_colors is not None
389389 assert sorted (img_colors ) == expected_colors
390390
391+ def test_alpha_composite_la (self ) -> None :
392+ # Arrange
393+ expected_colors = sorted (
394+ [
395+ (3300 , (255 , 255 )),
396+ (1156 , (170 , 192 )),
397+ (1122 , (128 , 255 )),
398+ (1089 , (0 , 0 )),
399+ (1122 , (255 , 128 )),
400+ (1122 , (0 , 128 )),
401+ (1089 , (0 , 255 )),
402+ ]
403+ )
404+
405+ dst = Image .new ("LA" , size = (100 , 100 ), color = (0 , 255 ))
406+ draw = ImageDraw .Draw (dst )
407+ draw .rectangle ((0 , 33 , 100 , 66 ), fill = (0 , 128 ))
408+ draw .rectangle ((0 , 67 , 100 , 100 ), fill = (0 , 0 ))
409+ src = Image .new ("LA" , size = (100 , 100 ), color = (255 , 255 ))
410+ draw = ImageDraw .Draw (src )
411+ draw .rectangle ((33 , 0 , 66 , 100 ), fill = (255 , 128 ))
412+ draw .rectangle ((67 , 0 , 100 , 100 ), fill = (255 , 0 ))
413+
414+ # Act
415+ img = Image .alpha_composite (dst , src )
416+
417+ # Assert
418+ img_colors = img .getcolors ()
419+ assert img_colors is not None
420+ assert sorted (img_colors ) == expected_colors
421+
391422 def test_alpha_inplace (self ) -> None :
392423 src = Image .new ("RGBA" , (128 , 128 ), "blue" )
393424
0 commit comments