From 555f5516b9fca96f9c87d1e8a406f4cd0cc3ba2e Mon Sep 17 00:00:00 2001
From: Classic298 <27028174+Classic298@users.noreply.github.com>
Date: Mon, 30 Nov 2026 19:55:15 +0100
Subject: [PATCH] perf: keep the server responsive while photos are prepared
for image editing (#35249)
When a photo is sent for an image edit, Open WebUI first rotates and re-encodes it so the provider sees it upright. That work stalled every other chat and request on the server for its full duration, about 130 ms per 12 MP photo and longer with each extra image in the request. It now runs without holding up other users, and the edited images are unchanged.
| Request | Longest server stall before | After |
| 1 photo (12 MP) | 136 ms | 23 ms |
| 3 photos (12 MP) | 377 ms | 19 ms |
Relates to #35245
---
backend/open_webui/routers/images.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/backend/open_webui/routers/images.py b/backend/open_webui/routers/images.py
index f2246ea6e7..227b331aa5 100644
--- a/backend/open_webui/routers/images.py
+++ b/backend/open_webui/routers/images.py
@@ -990,12 +990,12 @@ async def image_edits(
if isinstance(form_data.image, str):
image = form_data.image
if ENABLE_OPENAI_IMAGE_EDIT_NORMALIZATION:
- image = normalize_openai_edit_image_data_url(image)
+ image = await asyncio.to_thread(normalize_openai_edit_image_data_url, image)
files = [get_image_file_item(image)]
elif isinstance(form_data.image, list):
for img in form_data.image:
if ENABLE_OPENAI_IMAGE_EDIT_NORMALIZATION:
- img = normalize_openai_edit_image_data_url(img)
+ img = await asyncio.to_thread(normalize_openai_edit_image_data_url, img)
files.append(get_image_file_item(img, 'image[]'))
url_search_params = ''