✂️ Crop Image
Crop by exact pixels (not percent), keep your mask in lockstep
- image
- mask
- image
- mask
Sometimes you need a crop you can compute: "keep pixels 1352 through 2600 on the X axis, 136 through 968 on the Y" - the kind of exact cut you'd make in an image editor, not a proportional guess. The ✂️ Crop Image node does exactly that, in pixels, and it does the same crop to an optional mask at the same time so your mask stays perfectly aligned with the image. No percentages, no aspect-ratio math, no surprises.
How it works
You give it four numbers - pixels to cut from the top, bottom, left, and right - and it slices the image accordingly. If you also feed a mask, the identical crop is applied to it, which is the killer feature for inpaint or background-removal workflows where a misaligned mask quietly ruins your result. There's also a rotation input: it rotates clockwise by the angle you specify, expanding the canvas and filling the new corners with white (255 for masks). No auto-resize happens anywhere - the output is exactly the cropped size.
The math is refreshingly direct: crop_left and crop_top cut from the origin, crop_right and crop_bottom cut from the far edges. The README's example says it better than any paraphrase: for a 2600×1104 image, crop_left=1352, crop_right=0, crop_top=136, crop_bottom=136 yields exactly 1248×832.
Inputs and outputs
All crop amounts are integers (crop_top, crop_bottom, crop_left, crop_right, each 0–5000), plus rotation as a float from −180 to 180. The image and mask are both optional inputs, and both image and mask come out the other side - including as None if you didn't provide them, so don't assume the output exists just because the socket is there.
One subtlety worth knowing: the rotation is applied with white fill for the image and white for the mask. If you're cropping a transparent PNG and rotate it, the corners become opaque white rather than transparent - fine for most crops, annoying if you were counting on alpha. Also note the node sets Image.MAX_IMAGE_PIXELS = None, so it won't refuse to open huge source images the way some PIL-based nodes will.
When you'd reach for it
Batch face-cropping from a fixed template, removing letterbox bars, cutting a consistent region out of a camera burst before upscaling - the classic uses. It's also handy as a mask-correction step: crop a mask you generated at a different size down to match its image without touching the pixels themselves.
Gotchas
- If you crop more pixels than exist, PIL just returns an empty/small region rather than an error - check your numbers before you wonder why the output vanished.
- The node lives at the "crop the whole batch identically" end of the spectrum. If every image in your batch needs its own crop region, you want a loop or a per-image crop node, not this one.
Install
Part of Light-x02 Nodes. ComfyUI Manager → search "ComfyUI-Lightx02-Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Light-x02/ComfyUI-Lightx02-Nodes
Restart ComfyUI. It has no extra dependencies. One real footgun: this crop node also ships standalone in its own repo (ComfyUI_Crop_Image_By_Lightx02) - if you installed that version, delete it from custom_nodes or you'll see duplicate-node/registration errors alongside this pack.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| crop_top | INT | 00–5000 | — |
| crop_bottom | INT | 00–5000 | — |
| crop_left | INT | 00–5000 | — |
| crop_right | INT | 00–5000 | — |
| rotation | FLOAT | 0-180–180 | — |
| imageopt | IMAGE | — | |
| maskopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| mask | MASK | — |