adv crop
Expand, crop, fill, and even move an image using four numbers
- image
- mask
- image
- mask
- back_mask
adv crop is the swiss-army version of cropping in this pack: expand or crop each edge of an image and its mask independently, fill whatever new canvas gets created with a solid color or an edge-extension technique, and optionally move the whole image within its frame using the same four numbers you'd use to crop or pad it. It's a lot of node for what sounds like a simple operation, but the flexibility earns its keep once you're doing more than a plain rectangular crop.
The inputs and outputs that matter
up, down, left, right are the core controls - positive numbers expand the canvas in that direction, negative numbers crop into it, and you set all four independently or all at once. Background picks what fills the newly-expanded space when you're growing rather than shrinking: solid white or black, or one of three edge-extension styles - mirror (reflecting the edge pixels back), tile (repeating the image), or extend (stretching the boundary pixels outward, which tends to look most natural for subtle padding). InvertValue, InvertMask, and InvertBackMask flip the sign of your crop values and the two mask outputs respectively; the pack's documentation on these three is thin, so if a flip doesn't behave the way you expect, test it on one small image before building a whole workflow around the assumption.
Both image and mask are optional inputs, and - this is the one to remember - they don't need to match resolution going in. You can crop a mask that's a different size from the image it's paired with, as long as the crop amounts you request don't push either one past its own boundary. Three outputs come back: image, mask, and back_mask - a mask marking which pixels are original content versus newly-created background, available when you're working in mask-only mode without an image input. If you want a custom texture or color in the padded area instead of a flat fill, back_mask is your hook for blending one in yourself afterward.
One genuinely clever trick documented by the author: you can move an image within its canvas using nothing but the four crop values, by expanding on one side and cropping the opposite side by the same amount in the same operation - a negative left and a positive right of equal size shifts the visible content sideways without changing the overall canvas dimensions.
Installing it
Same install as the rest of ComfyUI-WJNodes. ComfyUI Manager: search "ComfyUI-WJNodes," install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git
Find it under WJNode → ImageEdit → ImageCrop. No models or extra dependencies needed.
Where people get burned
The author states it plainly: crop amounts that push past the actual image or mask boundary throw an error, and this is especially easy to trigger when your image and mask are different resolutions and you don't account for both when picking your numbers. If a run fails here, that's almost always the cause - check that your negative (cropping) values don't exceed either input's actual dimensions before assuming something else is wrong.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| up | INT | 0-32768–32767 | — |
| down | INT | 0-32768–32767 | — |
| left | INT | 0-32768–32767 | — |
| right | INT | 0-32768–32767 | — |
| Background | COMBO | 5 options: White, Black, Mirror, Tile, Extend | |
| InvertValue | BOOLEAN | false | — |
| InvertMask | BOOLEAN | false | — |
| InvertBackMask | BOOLEAN | false | — |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |
| back_mask | MASK | — |