From d189d5ba6763abb1fe480a410185158f74ca16b1 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 02:58:40 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20Fix=20RGBA=20to=20JPEG=20cr?= =?UTF-8?q?ash=20and=20BytesIO=20stream=20position?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Addressed code review feedback: - Fixed `OSError` when saving RGBA images as JPEG by converting to RGB. - Fixed `BytesIO` read issue by seeking to start of stream after writing. --- discord_image_node.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/discord_image_node.py b/discord_image_node.py index c04199f..863ac29 100644 --- a/discord_image_node.py +++ b/discord_image_node.py @@ -593,7 +593,13 @@ class DiscordSendSaveImage: file_bytes = BytesIO() # JPEG is always lossy, but we can set quality to maximum if lossless is requested jpeg_quality = 100 if lossless else quality - img.save(file_bytes, format="JPEG", quality=jpeg_quality) + + # Handle RGBA images for JPEG (which doesn't support alpha) + img_to_save = img + if img.mode == "RGBA": + img_to_save = img.convert("RGB") + + img_to_save.save(file_bytes, format="JPEG", quality=jpeg_quality) file_bytes.seek(0) else: