class

MJ::PixelSpec

Inherits YAML::Serializable < Reference < Object

Config for a pixel-art restyle. Lives as pixel.yml beside an image.png. Run: mj pixelize <dir> -> writes redraw.png (raw AI) + pixel.png (final).

The look ("8-bit" vs "16-bit") is driven by style, which selects a prompt template — Nano Banana 2 (google:4@3) infers pixel density and palette from the era name. width/ height set the CANVAS size, not the pixel granularity.

snap and background are independent optional post-passes:

  • snap: downscale to a true grid + quantize to colors + nearest upscale, for pixel-perfect authenticity. Off by default — the raw AI redraw already reads as pixel art. Requires ImageMagick (magick) on PATH.
  • background: "transparent" keys out a flat magenta chroma field (prompted for and removed); "keep" leaves the AI's background; "#RRGGBB" requests a solid colour bg.

Constructors

new(*, __context_for_yaml_serializable ctx : YAML::ParseContext, __node_for_yaml_serializable node : YAML::Nodes::Node)
Source

Instance methods

alpha_bleed
Source
alpha_bleed=(alpha_bleed : Bool)
Source
auto_background

Sample the actual rendered corner colour instead of keying the known magenta. Default FALSE: the redraw is prompted for flat #FF00FF, and corner-sampling can grab a floor/subject colour that reaches a corner (then the magenta never keys — leaving an opaque magenta field). Only set true if a model renders an off-magenta field but with clean, subject-free corners.

Source
auto_background=(auto_background : Bool)

Sample the actual rendered corner colour instead of keying the known magenta. Default FALSE: the redraw is prompted for flat #FF00FF, and corner-sampling can grab a floor/subject colour that reaches a corner (then the magenta never keys — leaving an opaque magenta field). Only set true if a model renders an off-magenta field but with clean, subject-free corners.

Source
background
Source
background=(background : String)
Source
colors
Source
colors=(colors : Int32)
Source
defringe
Source
defringe=(defringe : Bool)
Source
defringe_band

Restrict defringe to this many px of a transparent pixel. Default 2 (edge shell only) so legitimately magenta/pink pop-art colours in the SUBJECT interior are left alone.

Source
defringe_band=(defringe_band : Int32)

Restrict defringe to this many px of a transparent pixel. Default 2 (edge shell only) so legitimately magenta/pink pop-art colours in the SUBJECT interior are left alone.

Source
despill
Source
despill=(despill : Bool)
Source
grid
Source
grid=(grid : Int32)
Source
height
Source
height=(height : Int32)
Source
key_high
Source
key_high=(key_high : Int32)
Source
key_low

Transparent-background keying (only when background == "transparent"). Routed through the PROP keyer so edges get despilled and transparent pixels solidified — otherwise a magenta fringe outlines the sprite and resurrects when it's downscaled. Distance-from-magenta ramp (per-channel max, 0..255): below key_low = transparent, above key_high = opaque.

Source
key_low=(key_low : Int32)

Transparent-background keying (only when background == "transparent"). Routed through the PROP keyer so edges get despilled and transparent pixels solidified — otherwise a magenta fringe outlines the sprite and resurrects when it's downscaled. Distance-from-magenta ramp (per-channel max, 0..255): below key_low = transparent, above key_high = opaque.

Source
model
Source
model=(model : String)
Source
prompt
Source
prompt=(prompt : String)
Source
snap
Source
snap=(snap : Bool)
Source
style
Source
style=(style : String)
Source
width
Source
width=(width : Int32)
Source