Nodes/SDVN_Comfy_node/πŸ“ Mask Size
ComfyUI Node

πŸ“ Mask Size

Read a mask's width and height as integers

By StableDiffusionVNΒ·Created 2 years agoΒ·Updated about a month agoΒ· 118
πŸ“ Mask Size
  • mask
  • width
  • height

Tiny, boring, and exactly what a lot of mask workflows are missing: it reads the width and height of a MASK and hands them back as plain integers. That's it. The reason it exists is that mask-driven pipelines constantly need to know how big the mask is so they can size a latent, a crop, or an upscale to match - and there's no clean way to pull that off a mask without a helper node.

It's connective tissue for inpainting and segmentation graphs. When you're working with masks from a detector or a manual paint, feeding those dimensions downstream is how you keep everything aligned instead of hardcoding numbers that break the moment the mask changes shape.

How it works

You pass it a MASK, it measures the tensor, and it outputs two INTs. No model, no processing of the mask content - it's a straight dimension read. Whatever the mask's resolution is, that's what comes out.

The inputs and outputs that matter

One input, two outputs, nothing to configure:

  • mask - the mask to measure.
  • width / height (INT) - its dimensions. Wire them into an empty latent, a crop's target size, an upscale-to node, or any input expecting a dimension.

The typical pattern: a mask feeds both your inpaint node and this node, so the region you're regenerating and the latent you're regenerating it into agree on size.

How to install it

ComfyUI Manager: search SDVN_Comfy_node, install, restart. Or clone it:

cd ComfyUI/custom_nodes
git clone https://github.com/StableDiffusionVN/SDVN_Comfy_node

then pip install -r custom_nodes/SDVN_Comfy_node/requirements.txt from your ComfyUI root, and restart. It's under SDVN β†’ Mask.

Common issues & troubleshooting

The size doesn't match my image. A mask and its source image should be the same dimensions, but if the mask came from a resized or cropped source, it won't be. This node reports the mask's real size - if that's wrong, the mismatch happened upstream when the mask was made.

I wanted the size of a masked region, not the mask tensor. This returns the dimensions of the whole mask, not the bounding box of the white area inside it. If you need the tight bounds of the painted region, that's a crop-by-mask operation, not a size read.

Feeding these into a sampler errors. Diffusion latents want multiples of 8. If your mask lands on an odd size, round the values before they hit an empty latent, or bound them through a size helper.

Measuring an image instead of a mask? Wrong node - use Image Size in this pack, which takes an IMAGE or LATENT.

CategoryπŸ“‚ SDVN/🎭 Mask

Inputs (1)

NameTypeDefaultDescription
maskMASKβ€”

Outputs (2)

NameTypeDescription
widthINTβ€”
heightINTβ€”