zoey 图像批量裁剪器(全向自由裁剪)
Trimming the same borders off a whole folder? This node does it in one run
- output_folder
- processed_count
- error_count
- process_log
BatchImageCropper is the "crop every image in a folder the same way" node you reach for when you've generated or exported a pile of images and they all carry the same junk on the edges. Maybe your pipeline baked a watermark bar on the bottom of every frame. Maybe you trimmed a video into a folder of PNGs that all have identical black letterbox bars left and right. You tell the node how many pixels to shave off each side, point it at the folder, and it walks the whole directory with Pillow and writes fresh copies. No samplers, no graph gymnastics - it's a bulk file operation that happens to live inside ComfyUI because that's where your images already are.
It's one of the batch-saver/loader utilities in comfyui-ZoeyTool (the Zoey image-processing toolset, Zoey Tool/图像处理 style menus), and like most of that pack it does exactly one thing with zero mystery. Don't confuse it with an interactive crop node - there's no dragging a box over a preview. "全向自由裁剪" in the display name just means you can trim each of the four sides independently, which is the whole trick of it.
How it works
Point input_folder at a directory, optionally give it an output_folder, and set the four crop amounts: left_crop, right_crop, top_crop, bottom_crop, each in pixels. Every image in the folder gets the same trim applied - the node opens each file, computes the crop box as (left, top, width-right, height-bottom), saves the result, and moves on. file_types is a comma-separated list (default jpg,png,jpeg,bmp,tiff,webp).
A couple of design choices worth knowing:
- Leave
output_folderblank and it creates a timestampedcropped_YYYYMMDD-HHMMSSfolder next to your input, so your originals are untouched. That's the safe way to first run it. - With
preserve_nameson (default), output files keep their source names under acropped_prefix. Turn it off and it renames ascropped_0001,0002, … in the order found. overwriteoff means a name collision quietly becomes_1,_2, … instead of clobbering something.- If a crop would put the box outside the image (e.g. you trim 120px off a 100px-tall side), that file is logged as an error and skipped rather than crashing the batch.
The inputs and outputs that matter
Only a handful actually matter for a first run: input_folder, the four crop sliders, and whether you want overwrite on. Everything else has sane defaults.
It's not a pixel-output node - the real results are files on disk. The outputs are for bookkeeping: output_folder (the path it actually wrote to, useful to wire into a text/note node so you know where things landed), processed_count, error_count, and process_log, which is a readable per-file summary you can dump with any ShowText-style node.
Installing it
This ships in comfyui-ZoeyTool, so install the pack once and every Zoey node comes with it. Easiest is ComfyUI Manager - search the pack title comfyui-ZoeyTool and let it do the work. Manual route:
cd ComfyUI/custom_nodes
git clone https://github.com/liangzoey/comfyui-ZoeyTool.git
cd comfyui-ZoeyTool
pip install -r requirements.txt
Then restart ComfyUI. The node needs nothing beyond the pack's core Pillow/numpy deps, so no extra model downloads here. (Watch the README's dependency table vs the actual requirements.txt - the file is ground truth and it pulls in rembg and transformers whether you use them or not.)
Where people get burned
The classic one is feeding it a path with a trailing slash mismatch or a typo - it raises a clear "输入路径不存在" error, so the message is actually helpful. Second: remember the crop applies to every image equally, and files that end up with an invalid box after trimming get skipped with a log line, not an error stop - check processed_count against what you expected before deleting the originals. And since this writes real files, do your first test run into the auto-created timestamped folder, never straight over your source directory.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| input_folder | STRING | — | |
| output_folder | STRING | — | |
| file_types | STRING | jpg,png,jpeg,bmp,tiff,webp | — |
| left_crop | INT | 00–5000 | — |
| right_crop | INT | 00–5000 | — |
| top_crop | INT | 00–5000 | — |
| bottom_crop | INT | 00–5000 | — |
| overwriteopt | BOOLEAN | false | — |
| preserve_namesopt | BOOLEAN | true | — |
| prefixopt | STRING | cropped_ | — |
| suffixopt | STRING | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| output_folder | STRING | — |
| processed_count | INT | — |
| error_count | INT | — |
| process_log | STRING | — |