Nodes/ComfyUI-RMBG/Image Crop (RMBG) 🖼️
ComfyUI Node Runs on cloud

Image Crop (RMBG) 🖼️

Crop by size and anchor, and keep the leftover

By 1038lab·Created 2 years ago·Updated 8 days ago· 2,051
Image Crop (RMBG) 🖼️
  • image
  • CROP
  • REST
width256
height256
x_offset0
y_offset0
splitfalse
position

Crop a region out of an image by size and position, and - the part that makes this node worth reaching for - get the rest of the image back too. Most crop nodes throw away everything outside the crop. This one gives you both the crop and the remainder as separate outputs, which is exactly what you want when you're going to edit the cropped part and paste it back.

That two-output design is the whole reason to pick this over the built-in crop. Cut out a face, run it through a detailer or an edit model, then recombine it with the untouched remainder. The node keeps both halves so the recombine is possible without a second pass to reconstruct what you cut.

How it works

You set a crop size (width × height) and tell it where to anchor, either by a named position or by nudging with pixel offsets. It slices out that rectangle as CROP and returns everything else as REST.

The inputs that matter

  • width and height - the size of the crop rectangle.
  • position - a nine-way anchor: top-left, top-center, top-right, the center row, and the bottom row. This is the fast way to say "crop the top-right corner" without doing offset math.
  • x_offset and y_offset - fine positioning on top of the anchor. Positive/negative pixel nudges when the anchor gets you close but not exact.
  • split (default off) - toggles the split behavior for how the crop and remainder are divided. Leave off for a normal crop-plus-rest.

Outputs are CROP (the cut-out region) and REST (everything outside it). Send CROP into your editing chain, hold REST, and recombine at the end.

How to install it

  • ComfyUI Manager: search Comfyui-RMBG, install, restart.
  • Manual: cd ComfyUI/custom_nodes && git clone https://github.com/1038lab/ComfyUI-RMBG, then pip install -r requirements.txt, and restart.

No model - a plain image op, live as soon as the pack loads.

Common issues

The main thing to watch is a crop that runs off the edge of the image. If your width/height plus the anchor and offsets push the rectangle past the image bounds, you'll get a smaller or oddly-positioned crop than you expected. Keep the crop size within the source dimensions, and use position to anchor first before reaching for offsets - the named anchors are clamped sensibly, whereas large manual offsets are the fast way to slide the crop somewhere you didn't mean. If you're recombining CROP and REST later and the seam is off, make sure nothing resized the crop in between; the two halves only line back up at their original scale.

Category🧪AILab/🖼️IMAGE

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
widthINT2560–16384Width of the crop region in pixels. Will be clamped to image width.
heightINT2560–16384Height of the crop region in pixels. Will be clamped to image height.
x_offsetINT0Horizontal offset (in pixels) added to the crop position. Positive values move right, negative left.
y_offsetINT0Vertical offset (in pixels) added to the crop position. Positive values move down, negative up.
splitBOOLEANfalseIf True, output the cropped region and the rest of the image with the crop area set to zero. If False, the rest is a zero image.
positionCOMBOAnchor position for the crop region. Determines where the crop is placed relative to the image.

Outputs (2)

NameTypeDescription
CROPIMAGE
RESTIMAGE