DOGMA Resize Mask To Image v15
The two-wire fix for mask size mismatches
- mask
- image
- mask
Here is the most boring failure in ComfyUI masking, and the one that wastes the most afternoons. You segment something, you wire the mask into an inpaint node, and ComfyUI throws a shape error - or worse, silently composites your repair in the wrong place because the mask was a different resolution than the latent.
DOGMA Resize Mask To Image v15 exists for exactly that, and nothing else. Two inputs, one output, no parameters.
How it works
It takes a MASK and an IMAGE and conforms the mask to the image's canvas:
- a 2-D mask gets a batch dimension added,
- if the mask carries more than one layer, the layers are unioned with a max - not averaged, not concatenated,
- if the height and width don't match the image, the mask is bilinearly resized,
- values are clamped to 0–1.
That's the whole node. It is 20 lines of PyTorch and it earns its place by being explicit about the semantics: the mask comes back at the image's size, in the image's coordinate frame, and the union behaviour is documented by the code rather than left to a generic resizer.
Inputs and outputs
mask (MASK) and image (IMAGE), both required. One output: mask, ready to wire into a masked-latent, an inpaint conditioning, or the mask input of a stitch node. There is no mode switch, no interpolation choice, no "stretch vs. crop". If you need letterboxing or aspect-preserving padding, that is a different node's job.
Useful pairing: the DOGMA stitchers want a mask that lines up with the base image pixel-for-pixel, and this is the cheap way to guarantee it after a SAM pass that ran at a reduced resolution - which is exactly what DOGMASAMInputResizeV37 does upstream. That chain (downsize for the segmenter, resize the mask back up, then resize-union to the master) is the sanctioned shape of a low-VRAM semantic pass.
The catch that matters
The max-union. If you wire a six-pass category mask batch into this node, you get one mask containing all categories combined. That is sometimes what you want (one big inpaint mask for a global base pass) and almost never what you want when you are stitching per-category repairs, because each region needs its own mask to drive its own alpha ramp. Keep the categories separate through the stitch, and use this node for the union case - or for the case where you only ever had one mask and it was simply the wrong size.
The flip side: because it union-s a batch, a multi-layer mask from a segmentation node will not error out. It'll just quietly widen. If your inpaint is repainting more than you asked for, check whether a batch of masks got merged here.
Install
Manager → search DOGMA Nodes, or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
Restart ComfyUI afterwards. No Python dependencies (requirements.txt: "No external dependencies"), no model files - this is a pure tensor utility and it will work the moment ComfyUI imports the pack. It lands under the DOGMA/Semantic Detailer category, so if you can't find it in the node search, type "resize mask" and look for the DOGMA prefix.
A word on the pack itself: DOGMA Nodes is by axior, the studio half of a Milan production team that does commercial work with heavy ComfyUI inpaint passes, and this pack is their in-house machinery for exactly that. That is why the nodes are blunt little utilities instead of configurable systems - they were written to solve one specific pipeline, and v15 is what's left after the pipeline stopped needing anything cleverer.
When not to bother
If your mask and image already agree, skip it. Adding a resize that does nothing costs you a scheduler hop and one more wire to debug, and every resize is a chance to introduce a half-pixel of registration drift. Reach for it when the shapes disagree, not as a habit.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| image | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |