[GH-ISSUE #5096] No deterministic pixelize/quantize post-process for AI-generated pixel art #2819

Closed
opened 2026-10-21 05:56:09 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Aug 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5096

Originally assigned to: @kolacheee on GitHub.

The gap

Image models asked for pixel art return approximately pixel art: anti-aliased edges, off-grid pixels, soft alpha, drifting palettes. There is no deterministic post-processing step to turn that probabilistic output into an asset that can sit next to authored pixel art — no nearest-neighbour downscale to a target cell size, no palette quantization, no binary-alpha threshold, and no seam check for tileability. (The surrounding machinery already exists and works: the sprite routes emit a strict sheet-layout prompt contract, slice returned sheets with real sharp.extract(), and run provider-agnostic chroma-matte background removal per cell.)

Suggested fix

A small self-contained POST /api/sprites/pixelize route + service: nearest-kernel downscale to a caller-specified cell size, palette quantization against a caller-supplied ramp, binary alpha threshold, and a centre-crop seam score for tileability, returning the processed PNG plus an accept/reject report. Obtain sharp exclusively through the existing lazy getSharp() loader (packages/server/src/services/image/sharp-runtime.ts) so platforms without a sharp prebuild get the same actionable error every other image path gets. Shaped like the existing standalone cleanup routes so a client-only capability package can call it over REST.

Input bounds matter: cap accepted dimensions before allocating (pixelization holds several full-resolution buffers — phone memory).

From the pixel-RPG exploration roadmap (PR-D1); together with the sprite styleProfileId gap this is what makes AI-baked pixel tiles/sprites reliable. Verified against current staging (no pixelize service exists).

Originally created by @kolacheee on GitHub (Aug 15, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5096 Originally assigned to: @kolacheee on GitHub. ### The gap Image models asked for pixel art return *approximately* pixel art: anti-aliased edges, off-grid pixels, soft alpha, drifting palettes. There is no deterministic post-processing step to turn that probabilistic output into an asset that can sit next to authored pixel art — no nearest-neighbour downscale to a target cell size, no palette quantization, no binary-alpha threshold, and no seam check for tileability. (The surrounding machinery already exists and works: the sprite routes emit a strict sheet-layout prompt contract, slice returned sheets with real `sharp.extract()`, and run provider-agnostic chroma-matte background removal per cell.) ### Suggested fix A small self-contained `POST /api/sprites/pixelize` route + service: nearest-kernel downscale to a caller-specified cell size, palette quantization against a caller-supplied ramp, binary alpha threshold, and a centre-crop seam score for tileability, returning the processed PNG plus an accept/reject report. Obtain sharp exclusively through the existing lazy `getSharp()` loader (`packages/server/src/services/image/sharp-runtime.ts`) so platforms without a sharp prebuild get the same actionable error every other image path gets. Shaped like the existing standalone cleanup routes so a client-only capability package can call it over REST. Input bounds matter: cap accepted dimensions before allocating (pixelization holds several full-resolution buffers — phone memory). From the pixel-RPG exploration roadmap (PR-D1); together with the sprite `styleProfileId` gap this is what makes AI-baked pixel tiles/sprites reliable. Verified against current `staging` (no pixelize service exists).
bsakaguchi 2026-10-21 05:56:09 +07:00
Author
Owner

@kolacheee commented on GitHub (Aug 15, 2026):

Taking this one (agent working from kolacheee's fork) — draft PR is up. One finding worth flagging beyond the feature: sharp's png() encoder silently enables palette quantization when effort/quality are passed, which rewrites RGB under fully-transparent pixels to an arbitrary shared entry — the service pins palette:false explicitly and the new regression asserts normalized transparency so it can't regress.

<!-- gh-comment-id:5304343978 --> @kolacheee commented on GitHub (Aug 15, 2026): Taking this one (agent working from kolacheee's fork) — draft PR is up. One finding worth flagging beyond the feature: sharp's png() encoder silently enables palette quantization when effort/quality are passed, which rewrites RGB under fully-transparent pixels to an arbitrary shared entry — the service pins palette:false explicitly and the new regression asserts normalized transparency so it can't regress.
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#2819
No description provided.