✂️ 智绘_精确图像裁剪
Crop by pixels or percentage — the exact-cut node with no guesswork
- image
- cropped_image
ComfyUI's core crop nodes are awkward for the simplest request: "cut off 20 pixels from the bottom and 10 from the right." That's the exact, boring job ZH_ImageCropper (✂️ 智绘_精确图像裁剪) does - and it does it in two units of measure, which is what makes it genuinely useful. Pixels mode for precise cuts you can compute, Percentage mode for crops that survive resolution changes. IMAGE in, cropped IMAGE out, no masks, no node-soup. It's the "exact" (精确) in the name, and that's the whole point of existing.
How it works
The crop is defined by four inset values - top, bottom, left, right - each the amount cut away from that edge. The crop_mode dropdown decides what those numbers mean:
- Pixels (像素) - the numbers are literal pixel counts. Crop a 2048×1152 image by top=0, bottom=32, left=0, right=0 and you get 2048×1120, clean and predictable. This is the mode for "trim the watermark strip" or "remove exactly the black bars I know are there."
- Percentage (百分比) - the numbers are percentages of each edge's dimension. Crop 10% off the bottom of a 1024×1024 and you lose ~102px; run the same node on a 2048×2048 later and it loses ~205px - the crop scales with resolution. That's the mode for a crop you'll re-run across a folder of mixed sizes.
Under the hood it's plain Pillow crop() - tensor out, convert, crop, tensor back. Nothing clever, nothing to go wrong, effectively free.
The inputs that matter
crop_mode first (it changes what all four numbers mean - don't set it and forget it), then the four insets. The defaults are all 0, which means the node is a no-op pass-through until you set at least one value - a nice safety property. Output: a single cropped_image (IMAGE). Note the insets max out at 10000 in either mode; for pixel mode that's generous, for percentage it just caps at a full removal.
Install
Part of the 智绘灵箱 (ComfyUI-ZhiHui) pack:
cd ComfyUI/custom_nodes
git clone https://github.com/zhuyungen/ComfyUI-ZhiHui.git
Restart ComfyUI (or ComfyUI Manager, "智绘灵箱" / "ComfyUI-ZhiHui"). Pillow-only at runtime.
Where people get burned
- Inset order is the classic trip-up. top/bottom/left/right are four separate fields, and cropping "the bottom" means setting
bottom, nottop. It sounds obvious; the number of posts about it says otherwise. - Percentage is per-edge, not per-image. 10% off each edge isn't 10% of the area - it's 10% of width from left/right and 10% of height from top/bottom. The visual effect differs between square and landscape inputs.
- No output size guarantee. If you need the result at an exact resolution, pair this with a resize - the cropper only cuts, it doesn't resample.
- It's destructive-by-position, not mask-based. If your crop needs to be relative to a detected subject, that's a mask/crop-by-mask workflow; this node only does fixed geometric insets.
Honestly? For the "trim exactly N pixels" chore it's the node I'd reach for over dragging the core crop around - the percentage mode especially, because it turns a one-off crop into a reusable workflow that behaves identically at any resolution. Small, precise, and done.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| crop_mode | COMBO | Pixels (像素) | 2 options: Pixels (像素), Percentage (百分比) |
| top | INT | 00–10000 | — |
| bottom | INT | 00–10000 | — |
| left | INT | 00–10000 | — |
| right | INT | 00–10000 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| cropped_image | IMAGE | — |