Int Mask Side Length
The mask version of 'what's the shortest side' — for when masks carry the dimensions
- mask
- int
Same idea as the pack's Int Image Side Length, but for masks. Masks are single-channel tensors, and in ComfyUI they don't always match the image they're associated with - masks can be a different resolution entirely, especially when they've been through a segmentation model or a resize that only touched the mask path. When your downstream logic depends on the mask's geometry specifically, you want to measure the mask, not the image. This node gives you that measurement as a single INT.
The mode dropdown matches its image sibling: shortest (default), longest, width, or height. Internally it reads the mask tensor's H×W and picks the value your mode asks for. Return a 0 on malformed input rather than exploding, plus a text readout on the node so you can see what it found.
When you'd actually use this
The honest answer is: when the mask is the thing you're resizing or aligning. A very common ComfyUI headache is a mask that's been downscaled by a preprocessor or upscaled by a ControlNet while the image stayed put - and then everything downstream is off by a factor. Wiring this node into your resize logic ("pad this mask up to longest side 1024") keeps the mask's geometry honest instead of assuming it matches the image. It's also handy for decisions like "is this mask landscape or portrait?" before you feed it to a crop or an inpaint node that cares about orientation.
If you need both sides as separate wires, grab Int Image Size on the image path or use the mask's sibling size node where available - but for the common "I just need the short side of this mask as a number" case, this is the one-wire answer.
Installing it
It's in 1hewNodes. ComfyUI Manager → search "ComfyUI 1hewNodes" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/1hew/ComfyUI-1hewNodes
Restart ComfyUI. No special deps, no model downloads.
Common issues
The usual: it measures the first mask in the batch, so mixed-size mask batches report the head. And 0 on a broken input is silent - if your math downstream goes dark, check the mask wire. One mask-specific trap to note: if you connect an RGBA image (4-channel) where a mask is expected, the dimension indexing can read the wrong axis and give you a nonsense number, so make sure what's plugged in is actually a MASK type, not an image that looks like one.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| mode | COMBO | shortest | 4 options: longest, shortest, width, height |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| int | INT | — |