MJ::Pixelize
Pixel-art restyle via Nano Banana 2 (google:4@3), with optional transparency keying and an optional deterministic pixel-perfect "snap" pass.
Stage 1 (the look): the AI redraws the image as 8-bit / 16-bit pixel art — driven by the
style prompt, NOT by numeric knobs. Requires the current model (4@3/4@2); the old
google:4@1 refuses restyles.
Stage 2 (optional authenticity): downscale to a true grid + quantize to N colours +
nearest upscale. Works cleanly here precisely because Stage 1 already drew pixel-art
forms. Uses ImageMagick (magick).
Constants
Class methods
Stage 2: turn a raw redraw into the final sprite (snap + background keying).
Key the flat magenta field to transparent using the PROP keyer, so pixel-art edges get despilled/defringed and transparent pixels solidified (alpha-bleed). The bare distance key used to leave the chroma colour in edge + transparent pixels, which showed as a magenta outline (and resurrected on downscale). Thresholds/toggles come from the PixelSpec.
Stage 1: raw AI redraw. Returns the PNG bytes as generated.
Deterministic pixel-perfect pass via ImageMagick: downscale to grid, quantise to
colors (flat, no dither), nearest-upscale back to the canvas size.