[PR #13846] [MERGED] x/imagegen: add image edit capabilities #14415

Closed
opened 2026-04-13 00:53:24 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13846
Author: @jmorganca
Created: 1/22/2026
Status: Merged
Merged: 1/23/2026
Merged by: @jmorganca

Base: mainHead: focused-morse


📝 Commits (5)

  • 513ed95 x/imagegen: add support for image editing
  • 6c27570 x/imagegen: limit input images to 2 and remove obvious comment
  • 0bd3dfa bug fixes
  • 9386270 remove --image flag
  • f92a786 fix gofmt formatting in ImageEditRequest struct

📊 Changes

12 files changed (+653 additions, -21 deletions)

View changed files

📝 middleware/openai.go (+46 -0)
📝 middleware/openai_test.go (+126 -0)
📝 openai/openai.go (+44 -0)
📝 openai/openai_test.go (+83 -0)
📝 server/images.go (+0 -6)
📝 server/images_test.go (+9 -0)
📝 server/routes.go (+8 -1)
📝 server/routes_generate_test.go (+154 -0)
📝 x/imagegen/cli.go (+88 -2)
📝 x/imagegen/models/flux2/flux2.go (+14 -0)
📝 x/imagegen/runner/runner.go (+65 -6)
📝 x/imagegen/server.go (+16 -6)

📄 Description

Adds image edit capabilities for the FLUX.2-Klein models

API & Server:

  • New /v1/images/edits OpenAI-compatible endpoint with ImageEditRequest struct
  • Passes input images through to the image generation runner

Runner:

  • Added ImageEditModel interface for models supporting image input
  • Validates max 2 input images
  • Defaults width/height to first input image dimensions (scaled proportionally so max dimension is 1024)
  • Returns "model does not support image editing" for incompatible models

CLI (x/imagegen/cli.go):

  • Added image path detection in prompts (e.g., /path/to/image.png make it cartoon)
  • Reuses pattern matching from cmd/interactive.go for file path extraction

Models:

  • flux2 implements GenerateImageWithInputs for image editing support
  • Models declare vision capability via config to indicate image editing support

🔄 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/ollama/ollama/pull/13846 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 1/22/2026 **Status:** ✅ Merged **Merged:** 1/23/2026 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `focused-morse` --- ### 📝 Commits (5) - [`513ed95`](https://github.com/ollama/ollama/commit/513ed952796b7ad10e291357c34317ac391a8a96) x/imagegen: add support for image editing - [`6c27570`](https://github.com/ollama/ollama/commit/6c27570058abeb92676daebf608bb1b1bcfa2cd2) x/imagegen: limit input images to 2 and remove obvious comment - [`0bd3dfa`](https://github.com/ollama/ollama/commit/0bd3dfa4c378f6c49efcb47e95eacbcc8a1d48ef) bug fixes - [`9386270`](https://github.com/ollama/ollama/commit/9386270dbbf1c26d5e8fe2ee7699ea74f3e59c89) remove --image flag - [`f92a786`](https://github.com/ollama/ollama/commit/f92a786ec8550f94063b310a6edb8b2e1d6612dd) fix gofmt formatting in ImageEditRequest struct ### 📊 Changes **12 files changed** (+653 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `middleware/openai.go` (+46 -0) 📝 `middleware/openai_test.go` (+126 -0) 📝 `openai/openai.go` (+44 -0) 📝 `openai/openai_test.go` (+83 -0) 📝 `server/images.go` (+0 -6) 📝 `server/images_test.go` (+9 -0) 📝 `server/routes.go` (+8 -1) 📝 `server/routes_generate_test.go` (+154 -0) 📝 `x/imagegen/cli.go` (+88 -2) 📝 `x/imagegen/models/flux2/flux2.go` (+14 -0) 📝 `x/imagegen/runner/runner.go` (+65 -6) 📝 `x/imagegen/server.go` (+16 -6) </details> ### 📄 Description Adds image edit capabilities for the FLUX.2-Klein models API & Server: - New /v1/images/edits OpenAI-compatible endpoint with ImageEditRequest struct - Passes input images through to the image generation runner Runner: - Added ImageEditModel interface for models supporting image input - Validates max 2 input images - Defaults width/height to first input image dimensions (scaled proportionally so max dimension is 1024) - Returns "model does not support image editing" for incompatible models CLI (x/imagegen/cli.go): - Added image path detection in prompts (e.g., /path/to/image.png make it cartoon) - Reuses pattern matching from cmd/interactive.go for file path extraction Models: - flux2 implements GenerateImageWithInputs for image editing support - Models declare vision capability via config to indicate image editing support --- <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-04-13 00:53:24 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#14415