Nodes/ComfyUI-tools_zero/可视化图像裁剪
ComfyUI Node

可视化图像裁剪

Crop by hand, in the graph, and get the matching mask for free

By AIGCZero·Created about a year ago·Updated about a year ago· 16
可视化图像裁剪
  • image
  • mask
  • 裁剪图像
  • 裁剪遮罩

Cropping an image in ComfyUI usually means loading it into an external editor, cropping, saving, and re-importing - or fussing with coordinate widgets and hoping you got the math right. Zero_ImageCropper replaces that with a modal crop window that opens right in the node: your image appears, you drag a selection box over the part you want, hit apply, and the node returns the crop. And because it's a graph node, it also returns the matching mask - so if you feed it a mask, you get the cropped version of that mask, aligned perfectly to the crop. That second output is what makes it worth installing.

It's from the AIGCZero/ComfyUI-tools_zero pack, one of two interactive nodes (the other is Zero_ColorAdjustment). Like its sibling, it works through a preview-and-commit loop between the node and the frontend.

What it does

Required input: image. Optional input: mask (a MASK tensor, e.g. from a segmentation or a doodle). When the node runs, a dialog pops up with your image; you draw a box around the region you want and apply. The node then returns two outputs:

  • 裁剪图像 - the cropped IMAGE, at the exact region you selected.
  • 裁剪遮罩 - the mask, cropped to the same coordinates. If you didn't provide a mask, you get an empty (all-zero) mask matching the crop size, so downstream nodes that expect a mask always get one.

The real workflow power is in the mask: crop a reference image for an IPAdapter or a ControlNet while simultaneously producing the mask that tells a re-generation step exactly which region you just isolated. Feed it a segmentation mask and the crop + cropped-mask pair drop straight into an inpainting setup.

How it works

Same interactive loop as Zero_ColorAdjustment, with a longer leash. The node sends the first frame as a preview, then blocks waiting for you - up to 30 seconds this time, since cropping takes longer than a slider tweak. On apply, it posts the crop coordinates (x, y, width, height) plus the cropped image data to a /zero_image_cropper/apply endpoint; the backend reconstructs the tensor and, if a mask was present, crops it with the same coordinates, clamping them to stay in bounds and resizing if the mask and image ever disagree on dimensions. If you cancel or time out, it returns the original image and either your original mask or a zero mask.

Installing it

Standard pack install. ComfyUI Manager → search "ComfyUI-tools_zero", or:

cd ComfyUI/custom_nodes
git clone https://github.com/AIGCZero/ComfyUI-tools_zero

Restart after cloning. The crop UI ships in the pack's web/ directory, so it only works in the interactive frontend, not over the raw API.

Where people get burned

The 30-second timeout is the main trap: the queue waits on you, and if you take too long or walk away, you get the uncropped original back and the run continues with data you didn't intend. Also - only the first frame of a batch is shown, so this is a single-image tool; feed it a video batch and you'll crop frame one and wonder why the rest are untouched. And remember the mask alignment only works if your input mask is the same size as the image - the node handles mismatches by resizing the crop, but a pre-scaled mask will quietly give you a misaligned result. Used interactively with matching inputs, though, it's one of the fastest ways to get a precise crop-plus-mask pair without leaving the canvas.

Categorytools_zero

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
maskoptMASK

Outputs (2)

NameTypeDescription
裁剪图像IMAGE
裁剪遮罩MASK