Crop Image with Coords
Crop a region, remember where it came from, and never lose your place
- image
- Cropped Image
- Coords
Every inpainting tutorial tells you the same thing: crop tight, inpaint small, paste back. The reason is simple - a small crop gets the model's full resolution budget instead of being squeezed, and you're not wasting VRAM generating pixels you'll throw away. Crop Image with Coords is the "crop" half of that, with one feature that makes it actually usable in a graph: it hands you the exact coordinates it used, so Paste Image with Coords can put the crop back precisely where it came from.
You could crop with a plain image-crop node, sure. But then you'd have to track the coordinates yourself, by hand, every time you change the crop. This node packages them up so the paste is always correct even when you tweak the numbers.
How it works
It slices the IMAGE tensor and reports the slice indices. The two modes:
- Default (center crop): give it
crop_handcrop_w, and it crops that many pixels from the center of the image. This is the mode for "crop a 512×512 square out of the middle of this pano." - Explicit (corner-to-corner): set
crop_h2andcrop_w2to values ≥ 1 and it crops[crop_h:crop_h2, crop_w:crop_w2]instead - i.e.crop_h/crop_wbecome the top-left corner andcrop_h2/crop_w2the bottom-right. This is how you grab an off-center region, like a face sitting to one side of a panorama.
Both crop_h2 and crop_w2 default to -1, which means "use center-crop mode."
Outputs are Cropped Image and Coords. The Coords output is a LIST of four ints - [start_h, end_h, start_w, end_w] - which plugs directly into Paste Image with Coords. The intended graph is: Crop → (inpaint / upscale / edit the crop) → Paste, with Coords wired straight across. The crop node is from Ben Egan's ComfyUI_pytorch360convert pack, but it's not 360-specific - it works on any image, and it's arguably the most generally useful node in the pack.
Gotchas
The crop is a plain slice, so a crop_h larger than the image height will give you an empty tensor rather than an error - double-check your numbers if the pasted result looks wrong. And it operates on BHWC tensors like all ComfyUI images, so batch images get cropped per-frame, which is fine for video-ish workflows too.
Install
Install the pack via ComfyUI Manager (search "ComfyUI_pytorch360convert") or git clone https://github.com/ProGamerGov/ComfyUI_pytorch360convert into ComfyUI/custom_nodes and restart. Its requirements.txt is empty, so you may need python -m pip install pytorch360convert for the pack to import. No models, no downloads - this node is pure slicing.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| crop_h | INT | 0 | — |
| crop_w | INT | 0 | — |
| crop_h2 | INT | -1 | — |
| crop_w2 | INT | -1 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| Cropped Image | IMAGE | — |
| Coords | LIST | — |