From f6aeebc608ec34a3aee6561017f0b2237ffcf590 Mon Sep 17 00:00:00 2001 From: Billy Bao Date: Fri, 7 Nov 2025 15:45:10 +0800 Subject: [PATCH] Fix: cannot write mode RGBA as JPEG (#11102) ### What problem does this PR solve? Fix #11091 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/app/picture.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rag/app/picture.py b/rag/app/picture.py index 7a08ad4f0..f260104f7 100644 --- a/rag/app/picture.py +++ b/rag/app/picture.py @@ -97,7 +97,13 @@ def vision_llm_chunk(binary, vision_model, prompt=None, callback=None): try: with io.BytesIO() as img_binary: - img.save(img_binary, format="JPEG") + try: + img.save(img_binary, format="JPEG") + except Exception: + img_binary.seek(0) + img_binary.truncate() + img.save(img_binary, format="PNG") + img_binary.seek(0) ans = clean_markdown_block(vision_model.describe_with_prompt(img_binary.read(), prompt)) txt += "\n" + ans