DOGMA Center Crop v23 — Remove Context Pad
The node that removes the context padding it insisted you add
- image
- reference
- image
- info
Two inputs and a number. That's the whole node: an image, a reference image, a scale factor, and out comes the image centre-cropped to exactly reference size × scale. It looks like filler in a 157-node pack, and it's actually the closing bracket on a pattern the rest of the pack opens.
The pattern it closes
Diffusion models get weird at the edges. Run a tile through a sampler and the outermost pixels are the ones most likely to gain invented detail, inconsistent lighting, or a hard seam where the tile meets its neighbour. The standard mitigation is to oversample: generate a slightly larger region than you need, then crop back to the part you actually want. That's the same instinct behind padding a bbox before inpainting - grounding boxes wrap the object and not its surroundings, so you expand them or the model has nothing to blend against.
DOGMA does this explicitly. There's a DOGMAReflectPadV23 node earlier in the chain that pads your working master with mirrored context before a pass. This node is what removes that padding afterwards and brings the canvas back to exactly double (or 1.5×, or whatever scale says) the reference - the reference usually being the crop or the reference latent that the pass was conditioned on. So the pair reads as: pad for context, generate, crop the context off. The name of the display is literally "Remove Context Pad."
The second use is more workmanlike: it's a sane way to land an arbitrary image on a model-friendly size. Give it a 1024-ish reference and scale = 2 and you get a 2× canvas whose dimensions are derived from something real rather than typed by hand. That's the same reasoning as aligning tile strides to the latent grid - if the geometry is derived from the thing you're upscaling, you stop chasing off-by-16 artefacts.
Inputs and outputs
- image (
IMAGE) - the thing you're cropping. - reference (
IMAGE) - the thing you're cropping to. Only its height and width are read, so any image of the right size works. - scale (
FLOAT, default 2.0, range 1.0–8.0, step 0.05) - target size isreference × scale, rounded.
Outputs are image (IMAGE) and info (STRING). Wire the image onward; read the info line, which tells you either the crop origin it used ((x0,y0) -> exact WxH) or, if the input was too small, that it fell back to a resize.
That fallback is the honest bit of the node. If your image is narrower or shorter than the target, a centre crop is impossible, so it bicubic-resamples up to the target and says so. You get output either way; you just get to know whether it was a crop or a stretch.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/axior/ComfyUI-DOGMA-Nodes
Or ComfyUI Manager → DOGMA Nodes; the author also publishes it as comfy node install comfyui-dogma-nodes. There is no dependency step at all - requirements.txt is one comment line, pyproject.toml has dependencies = [], and the module imports nothing beyond torch, numpy and ComfyUI's own helpers. No model downloads. MIT licensed.
Where people get burned
Feeding it the wrong reference. It doesn't care what's in the reference image, only its dimensions, so a mismatched reference silently gives you the right-shaped wrong thing - a crop of the wrong region at the right size. Check the info string; it names the crop origin and the exact output size, and a suspicious (0,0) means you asked for something as big as or bigger than the input.
The other one is expecting this to fix aspect ratio. It crops from the centre, period, so a wide reference on a tall image eats the top and bottom. If you need the whole frame preserved, that's outpainting territory, and the mask-based route is the one that guarantees the original pixels survive - see the inpainting doc on why that guarantee is the only thing masks still uniquely offer.
And the inevitable: the pack has since moved on to further versions of everything, and this file is _V23. There's no README entry for it, so if a downloaded workflow uses a sibling with a higher number, assume it's doing the same job with a tweak, not something exotic.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| reference | IMAGE | — | |
| scale | FLOAT | 2.001–8 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| info | STRING | — |