mirror of
https://git.mirrors.martin98.com/https://github.com/danielgatis/rembg
synced 2025-08-18 00:45:55 +08:00
fixed apply_background_color
to remove partial transparency too if the specified background color is fully solid
This commit is contained in:
parent
37bbf63500
commit
06c6c57559
@ -175,9 +175,8 @@ def apply_background_color(img: PILImage, color: Tuple[int, int, int, int]) -> P
|
|||||||
Returns:
|
Returns:
|
||||||
PILImage: The modified image with the background color applied.
|
PILImage: The modified image with the background color applied.
|
||||||
"""
|
"""
|
||||||
r, g, b, a = color
|
background = Image.new("RGBA", img.size, tuple(color))
|
||||||
colored_image = Image.new("RGBA", img.size, (r, g, b, a))
|
colored_image = Image.alpha_composite(background, img)
|
||||||
colored_image.paste(img, mask=img)
|
|
||||||
|
|
||||||
return colored_image
|
return colored_image
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user