Nodes/TrentNodes/Latent-Aligned Mask (Auto)
ComfyUI Node

Latent-Aligned Mask (Auto)

The set-and-forget latent mask

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
Latent-Aligned Mask (Auto)
  • mask
  • vae
  • mask
  • info
modebalanced
prevent_edge_artifactstrue
smooth_boundariestrue

Latent-Aligned Mask (Auto) is this pack's "I don't want to think about expansion pixels and blur units" option. Where the base node hands you five numeric knobs and the Simple one hands you four, this one gives you a mode dropdown and two checkboxes, and it bundles the sensible settings for you. The display name says "Auto" and it mostly earns it.

What the controls actually do

  • mode - conservative, balanced (default), or aggressive. These map to preset expansion/blur/threshold combos. Balanced is 8 latent-pixel expansion with 1 unit of blur at 0.5 threshold - the same as the base node's defaults. Conservative trims expansion to 4 with no blur; aggressive expands to 12, blurs 2, and drops the threshold to 0.4. If you don't know what you want, balanced is right.
  • prevent_edge_artifacts - a checkbox (on by default) that controls the expansion step. It's the anti-black-edge behavior; unchecking it zeroes the expansion.
  • smooth_boundaries - a checkbox (on by default) that controls the blur step. Unchecking gives you crisp, hard-edged latent blocks.

So the mental model is: the mode picks how much to do, and the checkboxes turn the two protective behaviors on or off. It still needs a VAE input, same as the base node - it runs the exact same detection and processing under the hood, it just wraps them in presets.

Outputs

  • mask - the aligned mask.
  • info - a STRING that tells you what actually happened: the detected compression factor, the mode, and the resolved expansion/blur/threshold values. This is the genuinely nice touch. Wire it into a Preview Text node and you get a small receipt for the run, so when a mask misbehaves you can see immediately that the VAE auto-detect picked 4× instead of 8×.

Install

Part of TrentNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt

Restart and it's under Trent/Masks. Same no-weights story as the rest of the family.

The trade

Honestly? If you've read the base node article and you know what expansion and blur mean, the numeric knobs give you finer control than a three-stop mode enum. The Auto version wins when you're building a workflow you'll share or revisit months later - the intent is legible, and info makes debugging cheap. The failure modes are the same as the base node: a VAE that auto-detects wrong (check info), and the output being binary rather than feathered (by design - it's for latent inpainting, not compositing). For a quick "just align this mask," it's the one I'd reach for.

CategoryTrent/Masks

Inputs (5)

NameTypeDefaultDescription
maskMASK
vaeVAE
modeCOMBObalancedHow much to expand: conservative=less, aggressive=more
prevent_edge_artifactsBOOLEANtrueAutomatically expand to prevent black edges
smooth_boundariesBOOLEANtrueSmooth mask boundaries in latent space

Outputs (2)

NameTypeDescription
maskMASK
infoSTRING