diff --git a/Tests/images/transparent_background_text.png b/Tests/images/transparent_background_text.png index 40acd92b6..8ddd65cc6 100644 Binary files a/Tests/images/transparent_background_text.png and b/Tests/images/transparent_background_text.png differ diff --git a/Tests/images/transparent_background_text_L.png b/Tests/images/transparent_background_text_L.png new file mode 100644 index 000000000..d37de20a7 Binary files /dev/null and b/Tests/images/transparent_background_text_L.png differ diff --git a/Tests/test_image_paste.py b/Tests/test_image_paste.py index 3740fbcdc..1d3ca8135 100644 --- a/Tests/test_image_paste.py +++ b/Tests/test_image_paste.py @@ -236,7 +236,7 @@ class TestImagingPaste: [ (127, 191, 254, 191), (111, 207, 206, 110), - (255, 255, 255, 0) if mode == "RGBA" else (127, 254, 127, 0), + (127, 254, 127, 0), (207, 207, 239, 239), (191, 191, 190, 191), (207, 206, 111, 112), diff --git a/Tests/test_imagefont.py b/Tests/test_imagefont.py index 883c14170..e843351ab 100644 --- a/Tests/test_imagefont.py +++ b/Tests/test_imagefont.py @@ -131,6 +131,9 @@ class TestImageFont: target = "Tests/images/transparent_background_text.png" assert_image_similar_tofile(im, target, 4.09) + target = "Tests/images/transparent_background_text_L.png" + assert_image_similar_tofile(im.convert("L"), target, 0.01) + def test_textsize_equal(self): im = Image.new(mode="RGB", size=(300, 100)) draw = ImageDraw.Draw(im) diff --git a/src/libImaging/Paste.c b/src/libImaging/Paste.c index 03b17f571..a1bf18a92 100644 --- a/src/libImaging/Paste.c +++ b/src/libImaging/Paste.c @@ -436,7 +436,7 @@ fill_mask_L( strcmp(imOut->mode, "La") == 0 || strcmp(imOut->mode, "LA") == 0 || strcmp(imOut->mode, "PA") == 0) && - i != 3) { + i != 3 && channel_mask != 0) { channel_mask = 255 - (255 - channel_mask) * (1 - (255 - out[3]) / 255); }