[PR #19822] [CLOSED] Fix #19750 : flow of image edit with reference #64210

Closed
opened 2026-05-06 09:36:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/19822
Author: @eml-henn
Created: 12/8/2025
Status: Closed

Base: devHead: fix-image-edit-with-reference


📝 Commits (2)

  • aa806d1 Fix #19750 : Handle reference images correctly in image edit
  • e4f7b3b Fix #19750 : Handle reference images correctly in image edit

📊 Changes

1 file changed (+14 additions, -8 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+14 -8)

📄 Description

Changelog Entry

Description

Fixes a bug where uploading a reference image after generating an image would ignore the previously generated image and only use the reference image.

Discussion here: https://github.com/open-webui/open-webui/discussions/19754

Fixed

Modified get_last_images() to:

  • Separate user-uploaded images from assistant-generated images
  • Prioritize latest supplied images for editing

Additional Information

  • Tested: Generate image → Upload reference → Edit (now correctly passes both images)
  • Tested: Upload reference → Generate (works as before)
  • Tested: Generate → Edit without reference (works as before)
  • Tested: Multiple parallel assistant chats with references (only active branch will be considered)
  • Tested successfully with editing capable models supported by OUI: openai gpt-image-1, gemini flash 2.5 image, gemini 3 pro preview.
  • [?] Tested unsuccessfully with openai dall-e-2 but for unrelated reasons (dall-2 can only accept a single image as reference, after 0c18cd67d5 we always pass an array, even with a single image). Fixing this in images.py uncovered a further error with dall-e-2 only supporting png in RGBA format, which is not how the assistant returns images (An error occurred while generating the image: [ERROR: Invalid input image - format must be in ['RGBA', 'LA', 'L'], got RGB.]) . Will document this further, up for discussion best way to fix this.
  • Need testing with ComfyUI

the current image creation / edit flow is as follows:
A) user1 w. no image → image creation method → assistant1 w. image
B) user1 w. image → image editing method → assistant1 w. image
C) user1 w. no image → assistant 1 w. image → user2 w. no image → image edit based on assistant 1
D) user1 w. image → assistant 1 w. image → user2 w. no image → image edit base on assistant 1 only
E) and F) user 1 w. or w.no image → assistant1 w. image → user2 w. image → image edit based on assistant 1 and user 2.
G) user1 w. image -> assistant1 w. no image (regular query) -> user2 w. no image with image request -> image edit based on user1

Screenshots or Videos

2025-12-08_16h26_52 2025-12-08_16h25_07 2025-12-08_16h26_10

Contributor License Agreement

By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/19822 **Author:** [@eml-henn](https://github.com/eml-henn) **Created:** 12/8/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-image-edit-with-reference` --- ### 📝 Commits (2) - [`aa806d1`](https://github.com/open-webui/open-webui/commit/aa806d12d089752f394490e29f73fc367d96ec24) Fix #19750 : Handle reference images correctly in image edit - [`e4f7b3b`](https://github.com/open-webui/open-webui/commit/e4f7b3b1569181e84c2757217a116ecf64e899f4) Fix #19750 : Handle reference images correctly in image edit ### 📊 Changes **1 file changed** (+14 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+14 -8) </details> ### 📄 Description # Changelog Entry ### Description Fixes a bug where uploading a reference image after generating an image would ignore the previously generated image and only use the reference image. Discussion here: https://github.com/open-webui/open-webui/discussions/19754 ### Fixed Modified `get_last_images()` to: - Separate user-uploaded images from assistant-generated images - Prioritize latest supplied images for editing --- ### Additional Information - [x] Tested: Generate image → Upload reference → Edit (now correctly passes both images) - [x] Tested: Upload reference → Generate (works as before) - [x] Tested: Generate → Edit without reference (works as before) - [x] Tested: Multiple parallel assistant chats with references (only active branch will be considered) - [x] Tested successfully with editing capable models supported by OUI: openai gpt-image-1, gemini flash 2.5 image, gemini 3 pro preview. - [?] Tested unsuccessfully with openai dall-e-2 but for unrelated reasons (dall-2 can only accept a single image as reference, after https://github.com/open-webui/open-webui/commit/0c18cd67d54af51a513144c9f48f0503c8182744 we always pass an array, even with a single image). Fixing this in images.py uncovered a further error with dall-e-2 only supporting png in RGBA format, which is not how the assistant returns images (An error occurred while generating the image: [ERROR: Invalid input image - format must be in ['RGBA', 'LA', 'L'], got RGB.]) . Will document this further, up for discussion best way to fix this. - [ ] Need testing with ComfyUI the current image creation / edit flow is as follows: A) user1 w. no image → image creation method → assistant1 w. image B) user1 w. image → image editing method → assistant1 w. image C) user1 w. no image → assistant 1 w. image → user2 w. no image → image edit based on assistant 1 D) user1 w. image → assistant 1 w. image → user2 w. no image → image edit base on assistant 1 **only** E) and F) user 1 w. or w.no image → assistant1 w. image → user2 w. image → image edit based on assistant 1 **and** user 2. G) user1 w. image -> assistant1 w. no image (regular query) -> user2 w. no image with image request -> image edit based on user1 ### Screenshots or Videos <img width="738" height="786" alt="2025-12-08_16h26_52" src="https://github.com/user-attachments/assets/654916c7-14af-4137-ab02-fcd08a6fd802" /> <img width="805" height="172" alt="2025-12-08_16h25_07" src="https://github.com/user-attachments/assets/e35a065a-ea70-4011-9fd5-f5aa86fe0c2c" /> <img width="775" height="634" alt="2025-12-08_16h26_10" src="https://github.com/user-attachments/assets/fcf95c40-ca71-4a9e-b664-e8a7d193a629" /> ### Contributor License Agreement By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-06 09:36:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#64210