Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Tests/test_image_paste.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ def test_image_solid(self, mode: str) -> None:
im = im.crop((12, 23, im2.width + 12, im2.height + 23))
assert_image_equal(im, im2)

def test_image_la_into_rgb(self) -> None:
# LA images are stored with two padding bytes per pixel.
# point() sets them to zero,
# so the image must be internally converted before pasting onto RGB
im = Image.new("RGB", (1, 1))

source = Image.new("LA", (1, 1), (128, 255)).point(lambda v: v)
im.paste(source)

assert im.getpixel((0, 0)) == (128, 128, 128)

@pytest.mark.parametrize("y", [10, -10])
@pytest.mark.parametrize("mode", ["L", "RGB"])
@pytest.mark.parametrize("mask_mode", ["", "1", "L", "LA", "RGBa"])
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ def paste(
source = ImageColor.getcolor(im, self.mode)
elif isinstance(im, Image):
if self.mode != im.mode and (
self.mode != "RGB" or im.mode not in {"LA", "RGBA", "RGBa"}
self.mode != "RGB" or im.mode not in {"RGBA", "RGBa"}
):
# should use an adapter for this!
im = im.convert(self.mode)
Expand Down
Loading