[PR #8759] [MERGED] fix(images): scale GPT Image 2.5 requests up to 1024x1536 pixels #8788

Closed
opened 2026-11-07 17:39:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8759
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/gpt-image-25-pixel-floor


📝 Commits (1)

  • aa2d777 fix(images): scale GPT Image 2.5 requests up to 1024x1536 pixels

📊 Changes

4 files changed (+36 additions, -11 deletions)

View changed files

📝 packages/server/src/services/avatars/generation/generation-context.ts (+10 -3)
📝 packages/server/src/services/image/image-generation.ts (+6 -2)
📝 scripts/regressions/avatar-generation.regression.ts (+3 -1)
📝 scripts/regressions/gpt-image-2-5.regression.ts (+17 -5)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

Closes #8758

Why this change

  • Packages such as Otome Hearth request ~1 MP SDXL bucket sizes: 768x1344 scenes, 832x1216 looks, 1024x1024 stickers and photos. The Engine sent those to GPT Image 2.5 (Flare/Sunburst) unchanged. That is below OpenAI's recommended 1024x1536 portrait, so small figures in multi-person scenes came out with broken hands and limbs.
  • GPT Image 2 already has a pixel floor. The maintainer asked for the same for 2.5 and accepted the cost.

What changed

  • GPT Image 2.5 images are larger, and cost about 1.5x as much (by pixel count) for ~1 MP requests. A request below 1,572,864 pixels (1024x1536) is now scaled up in its own shape. Each side stays a multiple of 16, within OpenAI's 8,294,400 px ceiling, 3840 px edge and 3:1 ratio. A request that already meets the floor is sent unchanged. Examples:
    • 768x1344 -> 960x1664
    • 832x1216 -> 1040x1520
    • 1024x1024 -> 1264x1264
    • 1536x864 -> 1680x944
  • The floor is a constant. openAIGptImage25Size already scaled requests up to the API minimum (655,360). It now uses OPENAI_GPT_IMAGE_25_MIN_PIXELS instead. No sizing logic was copied.
  • The avatar editor asks for a canvas the 2.5 rules keep. It places the sprite on the canvas it requests (PNGtuber blink and talk pictures), so for 2.5 it now asks for a canvas at the new floor. Otherwise 608x1792 would come back as 736x2160, another shape, and the sprite would no longer line up.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Manually generate an Otome Hearth scene (768x1344) on a real gpt-image-2.5 Flare or Sunburst connection. Confirm the debug log shows size 960x1664, the saved file is 960x1664, and hands and limbs in multi-person scenes look better.
  • Manually generate a 1024x1024 sticker or Photo Shoot photo on GPT Image 2.5. Confirm it comes back at 1264x1264.
  • Manually make a PNGtuber blink or talk variant from a tall sprite on GPT Image 2.5. Confirm the eyes and mouth still line up with the base sprite.
  • Manually generate a 2x2 portrait sprite sheet on GPT Image 2.5. Confirm the cells are cut correctly from the 1264x1264 result.

Agent-run checks (for reference):

  • Both edited regressions failed on the old code:
    • gpt-image-2-5: sent '1536x864' where '1680x944' was expected.
    • avatar-generation: the 736x2176 canvas case.
  • Both pass now.
  • These also pass: avatar-variant-composite, codex-chatgpt-image, toapis-media, image-custom-parameters, image-edit-reference, image-dimension-limit, sprite-background, provider-compat, and every image (28/28), sprite (7/7) and avatar-generation (2/2) regression.
  • The server type-check passes, and prettier is clean on the changed files.
  • An independent reviewer fuzzed the size function over 265,536 cases with 0 failures. Every output kept the size rules (multiples of 16, edge, ceiling, ratio), met the floor, and was unchanged when sent again.

Known limits, left as they are:

  • Gallery labels: gallery width/height labels still show the requested size, not the file's real size. This is display only, and the aspect ratio stays within about 1%.
  • OpenRouter: OpenRouter's GPT Image 2.5 path sends only an aspect ratio, so the floor doesn't apply there.
  • Avatar fallback: if an avatar edit falls back to another connection, the canvas was chosen for the primary model.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

No user-facing doc under docs/ states GPT Image 2.5 sizes.

🤖 Generated with Claude Code


🔄 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/Pasta-Devs/Marinara-Engine/pull/8759 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/3/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/gpt-image-25-pixel-floor` --- ### 📝 Commits (1) - [`aa2d777`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa2d777611b599eac9f23a8c2bdb1ae6a0d760a4) fix(images): scale GPT Image 2.5 requests up to 1024x1536 pixels ### 📊 Changes **4 files changed** (+36 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/avatars/generation/generation-context.ts` (+10 -3) 📝 `packages/server/src/services/image/image-generation.ts` (+6 -2) 📝 `scripts/regressions/avatar-generation.regression.ts` (+3 -1) 📝 `scripts/regressions/gpt-image-2-5.regression.ts` (+17 -5) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue Closes #8758 ## Why this change - Packages such as Otome Hearth request ~1 MP SDXL bucket sizes: 768x1344 scenes, 832x1216 looks, 1024x1024 stickers and photos. The Engine sent those to GPT Image 2.5 (Flare/Sunburst) unchanged. That is below OpenAI's recommended 1024x1536 portrait, so small figures in multi-person scenes came out with broken hands and limbs. - GPT Image 2 already has a pixel floor. The maintainer asked for the same for 2.5 and accepted the cost. ## What changed - **GPT Image 2.5 images are larger, and cost about 1.5x as much (by pixel count) for ~1 MP requests.** A request below 1,572,864 pixels (1024x1536) is now scaled up in its own shape. Each side stays a multiple of 16, within OpenAI's 8,294,400 px ceiling, 3840 px edge and 3:1 ratio. A request that already meets the floor is sent unchanged. Examples: - 768x1344 -> 960x1664 - 832x1216 -> 1040x1520 - 1024x1024 -> 1264x1264 - 1536x864 -> 1680x944 - **The floor is a constant.** `openAIGptImage25Size` already scaled requests up to the API minimum (655,360). It now uses `OPENAI_GPT_IMAGE_25_MIN_PIXELS` instead. No sizing logic was copied. - **The avatar editor asks for a canvas the 2.5 rules keep.** It places the sprite on the canvas it requests (PNGtuber blink and talk pictures), so for 2.5 it now asks for a canvas at the new floor. Otherwise 608x1792 would come back as 736x2160, another shape, and the sprite would no longer line up. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Manually generate an Otome Hearth scene (768x1344) on a real gpt-image-2.5 Flare or Sunburst connection. Confirm the debug log shows size 960x1664, the saved file is 960x1664, and hands and limbs in multi-person scenes look better. - Manually generate a 1024x1024 sticker or Photo Shoot photo on GPT Image 2.5. Confirm it comes back at 1264x1264. - Manually make a PNGtuber blink or talk variant from a tall sprite on GPT Image 2.5. Confirm the eyes and mouth still line up with the base sprite. - Manually generate a 2x2 portrait sprite sheet on GPT Image 2.5. Confirm the cells are cut correctly from the 1264x1264 result. Agent-run checks (for reference): - Both edited regressions failed on the old code: - `gpt-image-2-5`: sent '1536x864' where '1680x944' was expected. - `avatar-generation`: the 736x2176 canvas case. - Both pass now. - These also pass: `avatar-variant-composite`, `codex-chatgpt-image`, `toapis-media`, `image-custom-parameters`, `image-edit-reference`, `image-dimension-limit`, `sprite-background`, `provider-compat`, and every `image` (28/28), `sprite` (7/7) and `avatar-generation` (2/2) regression. - The server type-check passes, and prettier is clean on the changed files. - An independent reviewer fuzzed the size function over 265,536 cases with 0 failures. Every output kept the size rules (multiples of 16, edge, ceiling, ratio), met the floor, and was unchanged when sent again. Known limits, left as they are: - **Gallery labels:** gallery width/height labels still show the requested size, not the file's real size. This is display only, and the aspect ratio stays within about 1%. - **OpenRouter:** OpenRouter's GPT Image 2.5 path sends only an aspect ratio, so the floor doesn't apply there. - **Avatar fallback:** if an avatar edit falls back to another connection, the canvas was chosen for the primary model. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) No user-facing doc under `docs/` states GPT Image 2.5 sizes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:42 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8788
No description provided.