Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: cannot write mode RGBA as JPEG (#11102)

Billy Baof6aeebc608ec
diff --git a/rag/app/picture.py b/rag/app/picture.py
index 7a08ad4f07..f260104f70 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