DOGMA PadImageMask32 v2
The boring node that stops your VAE from refusing the tensor
- image
- mask
- IMAGE
- INT
- INT
- MASK
What it is
Two tensors in, four outputs out, and about fifteen lines of code. DOGMAPadImageMask32V2 takes an image and a mask, pads both on the right and bottom until the dimensions are multiples of 32, and returns the padded pair along with the new width and height.
That's the entire feature set. It exists because everything upstream of it in this pack cuts rectangles wherever the masks happened to be, and everything downstream of it wants dimensions the VAE will accept.
Why the mask gets padded to zero, and the image gets padded by replication
The padding modes are the interesting decision:
- The image is padded with
replicate- the edge row/column is repeated outward. Replicating instead of black-filling matters, because a black strip on the edge of a crop is a hard high-contrast line, and a VAE encode followed by a decode will happily turn that line into a visible artefact or a hallucinated dark border inside your tile. - The mask is padded with
0- the added strip is not part of the selection. So the extra pixels act as context the model can see but not repaint, which is exactly what you want when the padding is a leftover of grid alignment rather than something you meant to edit.
Depth used is right and bottom only, so your content stays anchored in the top-left. When you paste back, crop to the returned width/height or to your original size - don't assume the geometry survived the round trip.
Inputs and outputs
image(IMAGE) andmask(MASK) - they must already match. If the mask's H×W doesn't equal the image's, the node raisesDOGMA: image/mask geometry mismatch before VAE.That check is deliberate: ComfyUI masks get silently resized in a lot of pipelines, and this node refuses to guess which one is right.
Outputs, in order (the schema names them by type, so read the order carefully):
- padded image (
IMAGE) - padded width (
INT) - actual padded width, i.e.w + (-w % 32) - padded height (
INT) - padded mask (
MASK)
Wire the width/height into an Empty Latent Image or a VAE Encode geometry input, and the padded image/mask into the encode itself.
Why 32 in particular
VAEs downsample by 8, so 8 is the hard requirement for most models and 16 is common. 32 is the comfortable margin: it survives an extra downsample somewhere in the graph and it's what most SDXL/Flux-era workflows have converged on, since some families (Flux among them) want multiples of 64 to be truly happy. The KB's resolution table is the reference here - 32 is safe, 64 is safer if a node is still complaining.
The cost is up to 31 pixels on each axis, on top of whatever your crop already had. On a 4K frame that's noise. On a 512px tile you've just grown it up to 6%, which matters if you're counting pixels against a budget.
Where it sits
This is one of those nodes that's invisible when it works. The pipeline is: masks → crop windows at native resolution → render each tile → stitch back. Every one of those crops has arbitrary dimensions, and every one of them has to survive a VAE encode. Someone has to do the arithmetic, and doing it by hand in a graph is how you end up with a resize node that quietly scales by 1.02 and softens the crop you were trying to keep sharp.
Note the pairing with the rest of the pack: the crop nodes (DOGMANativeChunkCropsV2, DOGMAObjectNativeCropsV111) already pad each tile to 32 internally, and DOGMAFitDimensions32V2 computes grid-legal sizes for latents. This node is for the case where you're coming in from somewhere else - a manual crop, a mask from another pack, an image you resized with a float scale factor. If your dimensions came from a DOGMA crop node, you probably don't need it; if they came from anywhere else, check them.
Install
Manager → search DOGMA Nodes (publisher axior), or:
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
# restart ComfyUI
requirements.txt declares scipy>=1.10; this node imports nothing beyond torch. No model downloads, no ComfyUI core patches - the pack is explicit that its nodes neither download weights nor modify ComfyUI internals.
Completely honest assessment: this is a fifteen-line utility that any of the big plumbing packs already gives you in some form, and if you already have a pad-to-divisible node you like, there's no reason to switch. It earns its keep only because it's the pad step the DOGMA stitch assumes - same geometry convention, same metadata expectations, no rounding surprises across the seam.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| mask | MASK | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| INT | INT | — |
| INT | INT | — |
| MASK | MASK | — |