Image Crop
Crop an image without guessing pixel coordinates
- image
- IMAGE
- x
- y
Crop is one of those operations ComfyUI core doesn't make as friendly as it could. Image Crop (imageCrop) from the zsq_prompt pack fixes the annoying part: instead of typing raw x/y coordinates, you pick one of nine anchor positions (top-left, top-center, center, right-center, and so on) and let the node figure out the math. If you've ever needed to slice a region out of a generated image - a face area, a panel, a chunk to feed back into img2img - this is the friendly way to do it.
How it works
You tell it the crop width and height, pick a position anchor, and it calculates the crop origin so the box lands at that spot. The actual x and y coordinates it chose are returned alongside the cropped image, which is a genuinely nice touch: you always know exactly where the crop came from, so you can composite it back later.
Two safety behaviors worth knowing:
- Width and height are clamped to the source image, so asking for a 2000px crop out of a 1024px image just gives you the full image rather than an error.
- The
x_offset/y_offsetinputs let you nudge the box away from the anchor - including negative offsets. If you push it off-canvas, the node clamps back to the edges instead of exploding.
Inputs and outputs that matter
- image - the IMAGE to crop from.
- width / height - crop box size, step of 8 by default (handy for keeping dimensions SDXL-friendly).
- position - the nine-anchor dropdown. This is the one you'll actually touch.
- x_offset / y_offset - fine-tuning. Leave at 0 unless you need it.
- Outputs: IMAGE (the crop), plus x and y (the origin). Wire
x/yinto a composite or paste node if you want to put the crop back where it came from.
Where this fits in a workflow
The classic use is pre-processing for img2img or ControlNet: crop a face region, run it through a second pass, then composite the refined region back using the x/y outputs. It's also handy for working with grids - slice one cell out of a 2x2 generated batch for closer inspection. If your plan is "crop to a fixed size, then scale," the pack's imageResize and imageScaleDown nodes chain right after this one.
Installing zsq_prompt
All the nodes in this pack install together. In ComfyUI Manager, search zsq_prompt and install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/windfancy/zsq_prompt
Restart ComfyUI afterward. The pack's requirements are heavy - transformers, opencv-python, opencv-contrib-python, scikit-image, timm, onnx, ultralytics - so expect a real install, and don't panic if Manager flags a "conflicting with zsq_prompt" message on some downloaded workflow; that's Manager's dependency overlap detection being noisy, and it's misleading until you've actually installed the pack. No model downloads are needed for this node.
Gotchas
- This is a hard pixel crop, not a resize. If your crop size doesn't match the aspect ratio of the region, you get a smaller box, not a stretched one.
- The
x/youtputs are the crop origin in the original image's coordinate space - keep that in mind if you're pasting into a differently-sized canvas. - One light warning: it operates per tensor, so feed it a single image (batch 1) unless you intentionally want the same crop applied to every frame of a batch.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 2560–16384 | — |
| height | INT | 2560–16384 | — |
| position | COMBO | 9 options: top-left, top-center, top-right, right-center, bottom-right, bottom-center, +3 | |
| x_offset | INT | 0 | — |
| y_offset | INT | 0 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| x | INT | — |
| y | INT | — |