Nodes/Seb Nodes/Switch Mask (Seb)
ComfyUI Node

Switch Mask (Seb)

Switch Mask (Seb) picks for you

By cyberhirsch·Created about a year ago·Updated 8 months ago· 4
Switch Mask (Seb)
  • image
  • mask_21_9
  • mask_16_9
  • mask_3_2
  • mask_4_3
  • mask_1_1
  • mask_3_4
  • mask_2_3
  • mask_9_16
  • selected_mask
  • detected_ar_label

Switch Mask (Seb) solves a specific, annoying problem: you've built a post-processing pass - a vignette, a soft blur, an edge-darken - that needs a mask shaped for the image, and you keep generating at different aspect ratios. Wire up eight masks, one per shape, and this node hands back the right one automatically based on the incoming image. It's the difference between maintaining one universal workflow and maintaining a drawer full of per-ratio branches.

The use case from the README is the good one: combine this with a vignette or blur node, make masks for 16:9, 1:1, and 9:16, connect each to its input, and the same workflow now correctly processes any shape that comes through it. That's genuinely useful if you're a "one workflow, many outputs" person.

How it works

Dumb in the best way. The node looks at the image you feed it, computes its aspect ratio from the pixel dimensions, and finds which of eight fixed ratios it's closest to: 21:9, 16:9, 3:2, 4:3, 1:1, 3:4, 2:3, 9:16. Whichever mask input corresponds to that ratio gets passed through to the selected_mask output. There's no resizing, no blending, no guesswork - it picks a winner and hands it over.

The second output, detected_ar_label, is a plain string like "16:9" telling you which ratio it detected. It's a debugging gift - wire it into a text display node and you can see at a glance why a particular mask got chosen, or whether the node disagrees with you about the shape.

Inputs and outputs

The inputs are image plus eight mask_* slots, one per ratio: mask_21_9, mask_16_9, mask_3_2, mask_4_3, mask_1_1, mask_3_4, mask_2_3, mask_9_16.

The outputs are selected_mask (MASK) and detected_ar_label (STRING).

Two honest notes:

  • The masks are "required" in the schema but you can leave them disconnected. The node's failsafe is graceful - if the best-matching input has nothing connected, it passes None through rather than crashing. Your downstream node decides what "no mask" means, so build accordingly.
  • It selects, it doesn't transform. This node never resizes or rescales a mask to match the image. The mask you feed in has to already be the right size for your image, or the vignette lands off-center. The matching is purely about aspect ratio - check that your mask generation is producing image-sized masks.

Installing it

ComfyUI Manager, search "Seb", install, restart. Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/cyberhirsch/seb_nodes
# restart ComfyUI

No model files, no heavy dependencies - this one is pure Python and torch, so it's the least demanding node in the pack.

Honestly, this is a niche tool. If you render at one aspect ratio, you don't need it - just use a fixed mask. But if your output shapes vary and you want identical post-processing on all of them, it's the tidy way to get there. Small, single-purpose, does exactly what it says.

Categorymask/util/Seb

Inputs (9)

NameTypeDefaultDescription
imageIMAGE
mask_21_9MASK
mask_16_9MASK
mask_3_2MASK
mask_4_3MASK
mask_1_1MASK
mask_3_4MASK
mask_2_3MASK
mask_9_16MASK

Outputs (2)

NameTypeDescription
selected_maskMASK
detected_ar_labelSTRING