From dbf1c176106d489a2b28a97f2e74a3a7060b7bff Mon Sep 17 00:00:00 2001 From: calledit <1573053+calledit@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:27:24 +0100 Subject: [PATCH] Return a stream of RGB24 instead of a garbled mess of consecutive pngs --- rembg/commands/b_command.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rembg/commands/b_command.py b/rembg/commands/b_command.py index 21fc64a..702458e 100644 --- a/rembg/commands/b_command.py +++ b/rembg/commands/b_command.py @@ -135,9 +135,7 @@ def b_command( os.makedirs(output_dir, exist_ok=True) def img_to_byte_array(img: PILImage) -> bytes: - buff = io.BytesIO() - img.save(buff, format="PNG") - return buff.getvalue() + return img.convert('RGB').tobytes("raw", "RGB") async def connect_stdin_stdout(): loop = asyncio.get_event_loop()