diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.py index 13062f8b29..6740abbc58 100644 --- a/studio/backend/routes/inference.py +++ b/studio/backend/routes/inference.py @@ -860,6 +860,23 @@ async def openai_chat_completions( detail = "Image provided but current GGUF model does not support vision.", ) + # Convert image to PNG for llama-server (stb_image has limited format support) + if image_b64: + try: + import base64 as _b64 + from io import BytesIO as _BytesIO + from PIL import Image as _Image + + raw = _b64.b64decode(image_b64) + img = _Image.open(_BytesIO(raw)) + if img.mode == "RGBA": + img = img.convert("RGB") + buf = _BytesIO() + img.save(buf, format = "PNG") + image_b64 = _b64.b64encode(buf.getvalue()).decode("ascii") + except Exception as e: + raise HTTPException(status_code = 400, detail = f"Failed to process image: {e}") + # Build message list with system prompt prepended gguf_messages = [] if system_prompt: