Canny Image Cropper
Cropping a subject out of a canny map, padding included
- canny_image
- cropped_canny_image
This is the first rung of the pack's Canny chain - the "crop a subject's edges out of a full edge map so you can move it" trick. CannyImageCropper takes a canny edge map plus a bounding box (x, y, width, height) and cuts the subject's edges out of it, with optional padding. That's the entire job, and it's the same tensor-slice crop you'd hand-roll in three lines - but it's wired with the exact outputs of this pack's Mask Bounding Box node, which is the point.
Why would you crop a canny map? Canny ControlNet is how you force a model to respect the hard edges of a subject (our controlnet knowledge base calls it the classic for "architectural, mechanical, clean-contour" work). If you want to reposition a subject - pull it out of the frame, shrink it, drop it somewhere else - you don't regenerate from the whole image's edges. You crop the subject's edges, transform them, and feed the transformed edge map back to ControlNet so the model redraws the scene around the moved subject. This node is the crop step of that pipeline.
How it works
The crop is a plain tensor slice on the IMAGE tensor ([batch, y:y2, x:x2, :]). padding (default 5, 0–100) expands the box on all four sides before slicing, and the result is clamped to the image bounds so a box near the edge doesn't crash - it just crops less. Output is the cropped region, same channel layout as the input.
Inputs and outputs
- canny_image (
IMAGE) - the full canny/edge map. - x, y (
INT) - top-left of the box. - width, height (
INT) - box size. - padding (
INT, default 5) - extra margin around the box. A few pixels of breathing room usually helps ControlNet not clip the subject's edges, so 5 is a sensible default. - Output: cropped_canny_image (
IMAGE) - the region, ready for the next node in the chain.
Where the numbers come from
This node doesn't find the subject for you - you must supply the box. In practice those coordinates come from this same pack's Mask Bounding Box node (its x, y, width, height outputs match these inputs exactly), or from any detection node you already use. If you're typing numbers in by hand, expect to iterate: the crop is rigid, so a tight box that clips the subject's edges will make the regenerated subject look amputated.
Installing it
Part of Remade_nodes - install once for all 12 nodes:
cd ComfyUI/custom_nodes
git clone https://github.com/Pheat-AI/Remade_nodes
Restart ComfyUI, or search Remade_nodes in ComfyUI Manager. No models to fetch; the declared dependency is numpy, with the usual pack caveat that OpenCV (cv2) must exist in your environment or the whole pack fails to import - pip install opencv-python fixes it.
Nothing glamorous here, and that's fine. It's the disciplined first step of a subject-relocation workflow: clean crop of the edges you want to move, padding to keep them intact, and a clean handoff to the shrink and re-place steps that follow.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| canny_image | IMAGE | — | |
| x | INT | — | |
| y | INT | — | |
| width | INT | — | |
| height | INT | — | |
| padding | INT | 50–100 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| cropped_canny_image | IMAGE | — |