ZML_可视化裁剪图像
Crop with your mouse, four selection tools, no Photoshop — ZML_可视化裁剪图像
- 图像
- 图像
- 裁剪掉的图像
- 遮罩
ZML_可视化裁剪图像 is the "stop opening Photoshop" node. Wire an image in, click a button, and a crop UI opens right in the ComfyUI canvas where you drag a selection with your mouse. The coordinates get saved inside the node, so every run after that reproduces the exact same crop. It's the first thing I reach for when a batch of renders needs a consistent trim before compositing or upscaling.
The selection tools are the headline. 模式 offers four ways to draw the region:
矩形- classic drag-a-box crop圆形- circular/elliptical crop路径选择- freeform polygonal path画笔- paint a selection with a brush (lasso-style), for cutting out blobs no rectangle can capture
The mechanism: the crop region you draw is serialized to JSON and stored in the node's crop_data widget (you'll see it as a hidden multiline field - don't touch it by hand). At execution, the node parses that JSON, cuts the region out, and emits three outputs: the cropped 图像, the inverse 裁剪掉的图像 (everything you cropped away, which is genuinely useful for compositing), and a 遮罩 MASK matching the selection. That mask output is the sleeper: wire it into an inpaint or paste node and your visual crop becomes a region selector.
Supporting controls: 保持图像大小 (keep the original canvas, making the crop a masked-off region rather than a shrink), 裁剪比例 (lock 1:1, 16:9, 9:16, 4:3, 3:4 - this is how you force every crop to match a grid), and 裁剪宽度/裁剪高度 for exact pixel dimensions (step 8, so they land on latent-friendly multiples).
Installing it
Ships in ComfyUI-ZML-Image. ComfyUI Manager → ComfyUI-ZML-Image, or:
cd ComfyUI/custom_nodes
git clone https://github.com/zml-w/ComfyUI-ZML-Image
Restart. The crop editor runs in the browser (the pack bundles cropper.js and fabric.js for its visual tools), so no Python deps beyond the usual Pillow/numpy. Chinese UI; English patch at https://github.com/zml-w/ZZZ_ZML_English_Patch. README notes it "supports original-resolution output" - the 保持图像大小 path.
Common issues
The classic failure: crop looks right in the editor but the output is wrong. That almost always means the JSON in crop_data is stale or empty - if you clear it, the node bails and returns the original image plus an all-black mask (the source handles that case explicitly). Redraw the selection and run again.
The other gotcha is execution order. The visual editor is a frontend interaction - it writes crop_data but the actual crop happens when the workflow runs. If you change the input image's resolution after drawing a crop, the saved coordinates won't line up; this node assumes a stable input size. The 裁剪比例 locks help here: with a ratio set, the crop scales more gracefully than raw coordinates.
Also note the four modes produce different mask shapes, and the 画笔 lasso is the fiddliest - feathering isn't exposed, so hard-edged painted selections can show seams in a paste. For clean edges, 矩形 + 裁剪比例 is the reliable default. This is one of the pack's genuinely polished tools (it got a documented bug-fix pass in 2025.09), but it's still Chinese-first solo-dev software - give the mode you plan to rely on a test run before a big batch.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| 图像 | IMAGE | — | |
| 模式 | COMBO | 4 options: 矩形, 圆形, 路径选择, 画笔 | |
| 保持图像大小 | BOOLEAN | false | — |
| 裁剪比例 | COMBO | 6 options: 禁用, 1:1, 16:9, 9:16, 4:3, 3:4 | |
| 裁剪宽度 | INT | 00–8192 | — |
| 裁剪高度 | INT | 00–8192 | — |
| crop_data | STRING | {} | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| 图像 | IMAGE | — |
| 裁剪掉的图像 | IMAGE | — |
| 遮罩 | MASK | — |