[PR #372] [MERGED] fix(game): preserve generated asset image extensions #4586

Closed
opened 2026-10-22 04:08:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/generated-game-asset-image-extension


📝 Commits (1)

  • aa16882 fix(game): preserve generated asset image extensions

📊 Changes

2 files changed (+81 additions, -21 deletions)

View changed files

📝 packages/server/src/routes/game.routes.ts (+8 -4)
📝 packages/server/src/services/game/game-asset-generation.ts (+73 -17)

📄 Description

Linked issue

Closes #371

Why this change

  • Generated Game Mode backgrounds can be saved as .png even when the image provider returns JPEG bytes, especially when sharp is unavailable or fails before re-encoding.
  • Mismatched file extensions confuse image editors and make generated assets look corrupt or mislabeled.

What changed

  • Preserve the actual image extension when generated game backgrounds cannot be normalized through sharp.
  • Detect fallback image formats from file signatures before trusting provider metadata.
  • Let generated scene illustrations copied to the gallery use the saved asset extension instead of assuming PNG.
  • Share the generated background extension allowlist between the generator and route layer.

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

  • pnpm --filter @marinara-engine/server lint
  • pnpm --filter @marinara-engine/server test
  • pnpm --filter @marinara-engine/server build
  • No browser/UI manual verification performed; this is a server-side asset persistence fix.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A, server-side generated asset persistence fix.

Summary by CodeRabbit

Release Notes

  • New Features
    • Gallery background illustrations now support multiple image formats (PNG, JPEG, GIF, WebP, AVIF) instead of PNG only
    • Original image format is preserved during processing and storage

🔄 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/372 **Author:** [@TheLonelyDevil9](https://github.com/TheLonelyDevil9) **Created:** 5/3/2026 **Status:** ✅ Merged **Merged:** 5/3/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `main` ← **Head:** `fix/generated-game-asset-image-extension` --- ### 📝 Commits (1) - [`aa16882`](https://github.com/Pasta-Devs/Marinara-Engine/commit/aa16882439f78867f7755aa9cc7ca2224a19f15e) fix(game): preserve generated asset image extensions ### 📊 Changes **2 files changed** (+81 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/game.routes.ts` (+8 -4) 📝 `packages/server/src/services/game/game-asset-generation.ts` (+73 -17) </details> ### 📄 Description ## Linked issue Closes #371 ## Why this change - Generated Game Mode backgrounds can be saved as `.png` even when the image provider returns JPEG bytes, especially when `sharp` is unavailable or fails before re-encoding. - Mismatched file extensions confuse image editors and make generated assets look corrupt or mislabeled. ## What changed - Preserve the actual image extension when generated game backgrounds cannot be normalized through `sharp`. - Detect fallback image formats from file signatures before trusting provider metadata. - Let generated scene illustrations copied to the gallery use the saved asset extension instead of assuming PNG. - Share the generated background extension allowlist between the generator and route layer. ## 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 - `pnpm --filter @marinara-engine/server lint` - `pnpm --filter @marinara-engine/server test` - `pnpm --filter @marinara-engine/server build` - No browser/UI manual verification performed; this is a server-side asset persistence fix. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A, server-side generated asset persistence fix. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Gallery background illustrations now support multiple image formats (PNG, JPEG, GIF, WebP, AVIF) instead of PNG only * Original image format is preserved during processing and storage <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:08:57 +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#4586
No description provided.