From c8bd413e4cee558fd5f4b9e918d213424d9532f7 Mon Sep 17 00:00:00 2001 From: LIRUI YU <128563231+LiruiYu33@users.noreply.github.com> Date: Wed, 28 Jan 2026 14:59:02 +0800 Subject: [PATCH] Fixed bug: Prevent 400 errors from Image2Text providers by skipping images smaller than 11px on any side during figure enhancement. (#12868) ### What problem does this PR solve? During figure enhancement, some cropped figure images are extremely small. Sending these to the Image2Text/VLM provider fails with a 400 invalid_parameter_error because the image width/height must be >10px. This aborts the enhancement step. This PR adds a minimal size guard to skip tiny crops and continue processing. image ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- rag/app/picture.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rag/app/picture.py b/rag/app/picture.py index c60b7e85e..d8332fd76 100644 --- a/rag/app/picture.py +++ b/rag/app/picture.py @@ -105,6 +105,12 @@ def vision_llm_chunk(binary, vision_model, prompt=None, callback=None): txt = "" try: + # Skip tiny crops that fail provider image-size limits. + if hasattr(img, "size"): + min_side = 11 + if img.size[0] < min_side or img.size[1] < min_side: + callback(0.0, f"Skip tiny image for VLM: {img.size[0]}x{img.size[1]}") + return "" with io.BytesIO() as img_binary: try: img.save(img_binary, format="JPEG")