Nodes/RES4LYF/Image Crop Location Exact
ComfyUI Node Runs on cloud

Image Crop Location Exact

Crop by pixel coordinates, keep the paste-back data

By ClownsharkBatwing·Created 2 years ago·Updated 18 days ago· 1,222
Image Crop Location Exact
  • image
  • image
  • crop_data
x0
y0
width256
height256
edge

Most crop nodes make you eyeball a region or feed them a mask. This one takes coordinates. You give it a top-left corner and a width and height, and it cuts out exactly that rectangle - no rounding, no snapping to a multiple of 8, no guessing. If you already know the pixel box you want, this is the honest way to grab it.

The reason it's more than a convenience is the second output. Alongside the cropped image it hands you a crop_data blob that records where the crop came from. That's the piece that lets you do the detail-then-stitch dance: crop a region out, run a heavier sampler or an inpaint pass on just that patch, then paste it back into the original at the exact same spot with a matching "uncrop" node. Without the crop data you'd be lining the patch up by hand.

How it works

It's a straight tensor slice. x and y set the top-left corner in pixels, width and height set the size of the box, and the node returns that rectangle plus a record of the coordinates. The edge setting controls how the crop is anchored relative to the image's sides when things don't line up cleanly.

The inputs and outputs that matter

  • image (IMAGE) - the source.
  • x / y (INT) - the top-left corner of the crop, in pixels. 0,0 is the top-left of the image.
  • width / height (INT, default 256) - the size of the region to cut.
  • edge (original / short / long) - how the crop references the frame; original keeps the raw coordinate behavior, short/long anchor against the shorter or longer side.

Two outputs: image (IMAGE), the cropped patch, and crop_data (CROP_DATA), the coordinate record you feed to a paste-back node to recomposite the patch into the full frame.

Installing it

ComfyUI Manager: search RES4LYF, install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ClownsharkBatwing/RES4LYF/
cd RES4LYF
pip install -r requirements.txt

pip install inside your venv or portable Python, restart, hard-refresh with F5. No model downloads.

Where people get tripped up

The classic failure is asking for a box that runs off the edge of the image - x plus width larger than the source width, or the same on the vertical. Depending on the frame you'll get a clipped patch or an error, so sanity-check that your corner plus your size stays inside the actual dimensions. If you don't know them, pull the source through a "get image size" node first and drive width/height from that.

The other thing to remember: the crop_data output only matters if something consumes it. If you're cropping to composite back later, keep that wire connected all the way to your uncrop node - dropping it is how the patch ends up pasted a few pixels off, or not at all.

CategoryRES4LYF/images

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
xINT00–10000000
yINT00–10000000
widthINT2561–10000000
heightINT2561–10000000
edgeCOMBO3 options: original, short, long

Outputs (2)

NameTypeDescription
imageIMAGE
crop_dataCROP_DATA