Skip to content

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

FIX:Saving an RGBA image directly as JPEG will cause an error. If the… (#8399)

WuWeiFlowbc1b83761622
diff --git a/rag/svr/task_executor.py b/rag/svr/task_executor.py
index e5fed0bea5..b028f7125e 100644
--- a/rag/svr/task_executor.py
+++ b/rag/svr/task_executor.py
@@ -293,6 +293,9 @@ async def build_chunks(task, progress_callback):
if isinstance(d["image"], bytes):
output_buffer = BytesIO(d["image"])
else:
+ # If the image is in RGBA mode, convert it to RGB mode before saving it in JPEG format.
+ if d["image"].mode in ("RGBA", "P"):
+ d["image"] = d["image"].convert("RGB")
d["image"].save(output_buffer, format='JPEG')
async with minio_limiter:
await trio.to_thread.run_sync(lambda: STORAGE_IMPL.put(task["kb_id"], d["id"], output_buffer.getvalue()))