mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2701] [Issue]: PNG card export blanks non-PNG avatars (JPG/WebP/GIF/AVIF) with a 1x1 transparent image #1345
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1345
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2701
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Exporting a character as a PNG card discards the avatar image for any non-PNG avatar (JPG/WebP/GIF/AVIF), substituting a blank 1×1 transparent PNG. So a character whose avatar isn't a PNG loses its image entirely on export, breaking export and any export→import round-trip.
Expected behavior
Exporting a character as a PNG card should embed the character's actual avatar image (transcoding to PNG if needed), so the exported card displays the right picture.
Actual behavior
The PNG card builder embeds the card JSON into a PNG, but for the base image it only handles a PNG-source avatar; for a non-PNG avatar (JPG/WebP/GIF/AVIF) it falls back to a blank 1×1 transparent PNG instead of transcoding the real image. The exported
.pngcard therefore has the correct embedded character data but a blank/empty picture — total image loss.How it breaks the pipeline
Code trace (staging @
b826f8f4):buildCharacterCardPng/ the export route —routes/characters.routes.tsand/or the client export inBotBrowserView.tsx/card export util) embeds the tEXtcharachunk but uses a blank 1×1 transparent PNG as the base image when the source avatar is not already a PNG (no transcode of JPG/WebP/GIF/AVIF).Steps to reproduce
.jpg/.webp/.gif/.avif..pngshows a blank/transparent image (the data is intact, the picture is gone). Re-importing yields a character with no avatar image.Suggested fix
Transcode the avatar to PNG (e.g. via
sharp, already a dependency) before embedding, so the real image is preserved in the exported card regardless of source format — rather than substituting a blank 1×1 PNG.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of import/export round-trips. Many Chub/Janny avatars are WebP/JPG, so this commonly blanks the image on export. Part of a set of import/export fidelity issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@kolacheee commented on GitHub (Jun 21, 2026):
Clarification on exact location (verified against the working tree): The defect is solely in the SERVER route
GET /:id/export-pnginpackages/server/src/routes/characters.routes.ts(handler at lines 738-774; the bug is line 756:pngBuffer = imageInfo?.mimeType === "image/png" ? avatarBuffer : createMinimalPng();). BecauseisAllowedImageBuffer(security.ts:82-121) reports the avatar's true format, any non-PNG avatar takes thecreateMinimalPng()branch (a real 1x1 transparent PNG, defined at line 1188-1210), whileinjectTextChunkstill embeds thecharadata (line 768) — so the card has correct data but a blank picture. This route is the "Export as PNG card" / "compatible-png" action triggered frompackages/client/src/components/characters/CharacterEditor.tsx:791.The Code trace in this issue should drop the "
buildCharacterCardPng... and/or the client export inBotBrowserView.tsx/card export util" wording, because it is misleading: (1) there is NO function namedbuildCharacterCardPngon the server (grep returns zero hits there); (2) the onlybuildCharacterCardPnglives in the CLIENT atpackages/client/src/components/bot-browser/BotBrowserView.tsx:2958(used at line 2742 for Bot Browser cards), and it is already CORRECT — it draws the avatar to a canvas and callscanvas.toBlob(..., "image/png")(lines 2967-2974), which transcodes any browser-decodable format to PNG. Pointing a fixer there risks editing correct code or hunting for a server function that doesn't exist. The fix belongs only in the server route.Suggested patch (server only): transcode non-PNG buffers with the already-bundled
sharp(server dependency^0.34.5, already loaded viaawait import("sharp")in 5+ files), keeping the existing try/catch so a transcode failure still falls back tocreateMinimalPng():No new top-level imports are needed.
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed on the issue sweep branch: server PNG card export now keeps PNG avatars as-is, transcodes valid non-PNG avatar buffers through sharp before injecting the card metadata, and only falls back to the minimal PNG for invalid/unreadable/transcode-failed avatars. Final pnpm validation is intentionally deferred until the full sweep is complete.