Nodes/ComfyUI-ZoeyTool/zoey 图像批量裁剪器(全向自由裁剪)
ComfyUI Node

zoey 图像批量裁剪器(全向自由裁剪)

Trimming the same borders off a whole folder? This node does it in one run

By liangzoey·Created about a year ago·Updated 3 days ago· 5
zoey 图像批量裁剪器(全向自由裁剪)
    • output_folder
    • processed_count
    • error_count
    • process_log
    input_folder
    output_folder
    file_typesjpg,png,jpeg,bmp,tiff,webp
    left_crop0
    right_crop0
    top_crop0
    bottom_crop0
    overwritefalse
    preserve_namestrue
    prefixcropped_
    suffix

    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_folder blank and it creates a timestamped cropped_YYYYMMDD-HHMMSS folder next to your input, so your originals are untouched. That's the safe way to first run it.
    • With preserve_names on (default), output files keep their source names under a cropped_ prefix. Turn it off and it renames as cropped_0001, 0002, … in the order found.
    • overwrite off 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.

    CategoryImage Processing/Batch

    Inputs (11)

    NameTypeDefaultDescription
    input_folderSTRING
    output_folderSTRING
    file_typesSTRINGjpg,png,jpeg,bmp,tiff,webp
    left_cropINT00–5000
    right_cropINT00–5000
    top_cropINT00–5000
    bottom_cropINT00–5000
    overwriteoptBOOLEANfalse
    preserve_namesoptBOOLEANtrue
    prefixoptSTRINGcropped_
    suffixoptSTRING

    Outputs (4)

    NameTypeDescription
    output_folderSTRING
    processed_countINT
    error_countINT
    process_logSTRING