Nodes/ComfyUI_NAIDGenerator/Convert Mask Image βœ’οΈπŸ…πŸ…πŸ…˜
ComfyUI Node

Convert Mask Image βœ’οΈπŸ…πŸ…πŸ…˜

Convert a normal mask image into the downsampled format NovelAI wants

By bedovyyΒ·Created 3 years agoΒ·Updated 5 days agoΒ· 114
Convert Mask Image βœ’οΈπŸ…πŸ…πŸ…˜
  • image
  • IMAGE

NovelAI's inpainting API doesn't accept the same mask you'd feed a local ComfyUI inpaint node. It expects a downsampled, alpha-baked format where each 64px block of real space becomes an 8px block - and if you feed it a raw full-res grayscale mask, the region math goes sideways. MaskImageToNAID (you'll sometimes see it under its old name, "Convert Image to NAI Mask") is the little converter that fixes the format for you.

It's the most boring node in the pack, which is the compliment. One input, one output, no settings:

  • image in - whatever mask you have: a painted white-on-black PNG, the output of a segmenter, a thresholded alpha. Any non-black pixel is treated as "masked."
  • IMAGE out - the same mask, rescaled to NAI's downsampled grid and ready to feed into InpaintingOptionNAID's mask input.

The mechanism is worth knowing only because it tells you when you need this node and when you don't. Internally the pack computes a target size as ceil(width/64)*8 - that's the NAI canvas convention - then resamples your mask to it with a nearest-neighbor upscale and packs it into an RGBA image with the alpha derived from the non-black pixels. InpaintingOptionNAID actually applies this conversion itself on upload, so if your mask is already clean white-on-black, you can skip this node entirely. Reach for it when your mask comes from somewhere messy - an external tool, a ComfyUI MASK you've composited, a semi-transparent PNG - and you want to normalize it before it hits the inpaint path.

One real trap in that "anything non-black becomes masked" rule: anti-aliased edges and gray values widen your inpaint region on the backend's alpha threshold. If you find the API regenerating more than you drew, threshold your mask to hard black/white before converting.

This node is the current name for the converter in the pack's node registry (NODE_CLASS_MAPPINGS["MaskImageToNAID"]). If you're looking at a workflow that references ImageToNAIMask instead - same node, old class name, and comfy.icu still carries a separate page for it under "Convert Image to NAI Mask." Either one wires into the same InpaintingOptionNAID flow.

Setup is pack-standard: ComfyUI Manager β†’ search "ComfyUI_NAIDGenerator", or clone into custom_nodes/ and restart. It's a pure local transform - no Anlas, no API call, and it even works before you've configured a NovelAI token, so it's a handy smoke-test node for verifying the pack loads.

CategoryNovelAI/utils

Inputs (1)

NameTypeDefaultDescription
imageIMAGEβ€”

Outputs (1)

NameTypeDescription
IMAGEIMAGEβ€”