Smart Batch Resize π
Point it at a folder, get a training-ready dataset
- images
- count
The part of LoRA training that actually eats your evening isn't the training - it's the prep. You've got 200 high-res images sitting in a folder, and they need to be resized to a consistent longest side, snapped to a multiple of 8, and renamed into something a trainer won't choke on. Smart Batch Resize is the folder β dataset step in one node. Drop it on the canvas, point it at a folder, hit run, and it reads everything, resizes it, and saves the results into a subfolder with clean filenames. No upstream input, no downstream connection, no workflow gymnastics.
It's part of ComfyUI-CraftKit, a small pack aimed squarely at LoRA dataset pipelines. The rest of the pack (Smart Resize, Smart Resolution Multiplier, the prompt/profile switching pair) covers the generation side; this node is the bulk-preprocessing side.
How it works
Under the hood it's Pillow doing Lanczos resizing (bicubic, bilinear, and nearest are there if you want them), preserving aspect ratio by scaling off the longest side, then snapping both dimensions to a multiple - 8 by default, which is what SD/Flux latents want. Nothing fancy, which is the point: it's reliable plumbing, and it has no extra dependencies. Pillow, NumPy and PyTorch all ship with ComfyUI already, so there's no requirements.txt landmine waiting for you.
The genuinely useful bit is the filename builder. It assembles each output name from the parts you toggle on: a prefix (like headshot), the original filename, a sequential 3-digit counter, and a resolution suffix - joined by a delimiter. So photo_001_1024.jpg isn't hard to get. There's a status label on the node showing the summary, plus a Browse button for the input folder so you're not pasting paths blind.
The inputs that matter
You'll touch maybe five of these:
- Input folder - the source. Use the Browse button. Only files directly in the folder are scanned; subfolders are ignored.
- Longest side (px) - target for the longest edge, default 1024, with quick presets.
- Multiple of - 8 for SD/Flux; leave it alone otherwise.
- Prefix - the label prepended to every filename. This is how you keep categories straight.
- Use original name / Add counter - at least one of these must be on, or every output would get the same name and the node refuses to run.
Outputs are images (a list, mainly for previewing in the UI) and count. Both are optional - the node does its job even if you leave them dangling.
Installing it
ComfyUI Manager: search for ComfyUI-CraftKit and install. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/CraftopiaStudio/ComfyUI-CraftKit
Then restart ComfyUI. All nodes land under CraftKit in the menu, and because there are no extra dependencies, install is as painless as custom nodes get.
Where people get burned
- It's not recursive. Pointing it at a folder full of subfolders silently does nothing to them. Flatten your source first.
- Output goes inside the input folder, into a
resizedsubfolder by default - the code explicitly refuses to write into the same directory as the originals, so your source is safe, but it does mean running it twice can stack folders. skip_if_existsis smarter than it looks. It only skips a file if the existing output still matches the current settings, so if you lowerlongest_sideon a re-run, stale files get reprocessed instead of silently kept.- HEIC and AVIF are on the supported list, but only if your Pillow has the plugins. If not, those files are skipped with a console warning rather than crashing the batch - easy to miss if you're not watching.
Is it glamorous? No. But it's the kind of node that makes a 200-image dataset prep take one run instead of an hour of manual resizing - and that's the whole job.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| input_folder | STRING | Folder containing images to resize. Only files directly in this folder are scanned β subfolders are not included. | |
| longest_side | INT | 102464β8192 | Longest side target in pixels. Aspect ratio is always preserved. |
| multiple_of | INT | 81β128 | Snap both dimensions to a multiple of this value. Use 8 for SD/Flux. |
| interpolation | COMBO | lanczos | Resampling method. Lanczos is sharpest for downscaling. |
| upscale_if_smaller | BOOLEAN | true | Upscale images that are smaller than the target longest side. Turn off to only ever downscale, never upscale. |
| prefix | STRING | Label prepended to filename. E.g. 'headshot' β headshot_photo_001_1024.jpg | |
| use_original_name | BOOLEAN | true | Include the original filename in the output name. |
| use_counter | BOOLEAN | false | Add a sequential 3-digit counter to each filename (001, 002, ...). |
| counter_start | INT | 10β99999 | Starting number for the counter. Useful when processing multiple batches. |
| suffix_resolution | BOOLEAN | true | Append resolution to filename. E.g. photo_1024.png |
| delimiter | STRING | _ | Separator between filename parts. E.g. _ or - |
| folder_resolution | BOOLEAN | false | Append resolution to subfolder name. E.g. resized_1024 |
| folder_custom | STRING | resized | Subfolder name. Resolution is appended if 'Create resolution subfolder' is on. |
| output_format | COMBO | keep_source | File format for saved images. 'keep_source' preserves each file's original extension. jpg cannot store transparency. |
| alpha_mode | COMBO | auto | auto: preserve transparency only if the source has it. flatten: always composite onto white and output opaque RGB. keep: always output RGBA. jpg/bmp output always flattens regardless (those formats can't store alpha). |
| quality | INT | 951β100 | Compression quality for jpg/webp output. Ignored for png (always lossless). |
| skip_if_exists | BOOLEAN | true | Skip files that already exist in the output folder AND still match the current size settings. If longest_side/multiple_of/upscale_if_smaller changed since the file was made, it's reprocessed instead of skipped. |
| preview_limit | INT | 320β10000 | Max images to keep in memory for the preview output. All files are still processed and saved to disk; this only limits what's returned/previewed. 0 = no limit. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | β |
| count | INT | β |