Resize image to dimension
Resize to an exact size — crop or pad, your call
- image
- ui_widget
- image
- image_list
- count
Standard ComfyUI resize nodes mostly scale by a factor or fit into a box. LF_ResizeImageToDimension resizes to an exact width and height - and when the source aspect ratio doesn't match your target, it lets you decide whether to crop or pad. That decision is the whole value of this node, and it's the one beginners get wrong.
The two settings that matter:
resize_method- how the pixels are interpolated:bicubic(the default, and the right call for photos),bilinear/linear, ornearest/nearest exactfor pixel-art and hard edges where you don't want smoothing to smear your crisp pixels.resize_mode-croporpad. Crop scales the image up so the target size is filled and slices off the overflow (you lose edges, but the output is exactly your dimensions and the whole frame is covered). Pad scales to fit and fills the leftover space withpad_color, a hex value like000000for black. Nothing gets cut, but you get bars.
You set width and height directly (defaults are 832×1216 - the SDXL portrait pair). Because it takes image as "an input image tensor or a list of image tensors," it's batch-friendly out of the box: give it a batch and you get image and image_list back, plus a count output so downstream nodes can know how many images they're dealing with.
Where this earns its keep: standardizing a mixed batch before training or captioning. If you're building a training dataset, your images need to come out at one consistent resolution - and the KB's LoRA-training advice is that preprocessing consistency matters more than anyone wants to admit. This node gives you exact control over how that consistency is achieved: crop when you want to preserve the subject's framing at full bleed, pad when you can't afford to lose any pixels (product shots, documents, anything with content near the edges).
The honest gotcha is the crop: the default crop-mode behavior can cut heads off portraits and punch the middle out of wide shots, because it crops the center unless your source happens to match the target ratio. If you're resizing faces or text-heavy images, pad is usually the safer first try. And a reminder that this is a pixel resize - the "make the image bigger but keep it sharp" conversation is a different node entirely (that's upscaling, and it's a whole separate rabbit hole).
Install is the LF standard: ComfyUI Manager → "LF Nodes", or
cd ComfyUI/custom_nodes
git clone https://github.com/lucafoscili/comfyui-lf
then restart. No models, no heavy deps - this runs on CPU instantly. One pack-level note: comfyui-lf is frozen in legacy mode (still fully functional), with development continuing in lucafoscili/lf-nodes, where the same resize node lives.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image tensor or a list of image tensors. | |
| height | INT | 1216 | The target height for the output image. |
| width | INT | 832 | The target width for the output image. |
| resize_method | COMBO | bicubic | Method to resize the image. |
| resize_mode | COMBO | crop | Choose whether to crop or pad when resizing. |
| pad_color | STRING | 000000 | Color to use for padding if 'pad' mode is selected (hexadecimal). |
| ui_widgetopt | KUL_TREE | [object Object] | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| image_list | IMAGE | — |
| count | INT | — |