From 0671695e8e12e3475712ae68198e8abb347dbfd6 Mon Sep 17 00:00:00 2001 From: bigcat88 Date: Mon, 31 Oct 2022 16:16:16 +0300 Subject: [PATCH] Fixes #6706 --- Tests/test_image_convert.py | 14 ++++++++++++++ src/libImaging/Convert.c | 1 + 2 files changed, 15 insertions(+) diff --git a/Tests/test_image_convert.py b/Tests/test_image_convert.py index 902d8bf8f..3ede1b5e1 100644 --- a/Tests/test_image_convert.py +++ b/Tests/test_image_convert.py @@ -338,3 +338,17 @@ def test_matrix_identity(): # Assert # No change assert_image_equal(converted_im, im) + + +def test_rgba_premultiplied_to_rgb(): + im = Image.merge( + "RGBa", + [ + Image.new(mode="L", size=(1, 1), color=128), + Image.new(mode="L", size=(1, 1), color=255), + Image.new(mode="L", size=(1, 1), color=64), + Image.new(mode="L", size=(1, 1), color=64), + ], + ) + im = im.convert(mode="RGB") + assert im.getpixel((0, 0)) == (32, 64, 16) diff --git a/src/libImaging/Convert.c b/src/libImaging/Convert.c index 2b45d0cc4..d8c51d624 100644 --- a/src/libImaging/Convert.c +++ b/src/libImaging/Convert.c @@ -933,6 +933,7 @@ static struct { {"RGBA", "YCbCr", ImagingConvertRGB2YCbCr}, {"RGBA", "HSV", rgb2hsv}, + {"RGBa", "RGB", rgbA2rgba}, {"RGBa", "RGBA", rgba2rgbA}, {"RGBX", "1", rgb2bit},