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.
<img width="1084" height="494" alt="image"
src="https://github.com/user-attachments/assets/ad074270-94e6-4571-91c8-37df85212639"
/>

### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
LIRUI YU
2026-01-28 14:59:02 +08:00
committed by GitHub
parent 2c4499ec45
commit c8bd413e4c

View File

@ -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")