Resize Image ♾️Mixlab
Resize, pad, and grab the average color in one node
- image
- mask
- image list
- average_image
- average_hex
- mask
Resizing sounds like a solved problem until you actually need it to do the right thing - fit without distorting, pad the leftover space with a color that doesn't clash, and maybe tell you what the dominant color even is so you can pick a sensible pad. ResizeImageMixlab rolls all of that into one node: it resizes with a choice of fit modes, pads with a color you pick, and can compute the image's average color and hand it back. It's the "resize but make it useful" node in shadowcz007's mixlab pack.
The reason a fancy resize node beats a plain one: most workflows have a target resolution the model wants (say 512 or 1024 on a side), but your input rarely matches that aspect ratio. A dumb resize squashes it. This node lets you fit by width, by height, or overall, and fill the gaps rather than distort - and the average-color output means you can pad with a color drawn from the image itself, so the padding blends instead of screaming "letterbox."
How it works
You set a target width and height and a scale_option that decides how the image maps into that box. It scales accordingly, fills any remaining area with fill_color, and - if you turn on average_color - computes the mean color of the image, returning both a rendered average swatch and its hex string. A mask output tracks the real image region versus the padded area, which is handy for compositing later.
The inputs and outputs that matter
The few you'll actually set:
width/height(INT, default 512) - the target size.scale_option(enum) -width,height,overall, orcenter. This is the fit-mode selector: scale to match a chosen edge, fit overall, or center. Pick based on which dimension you care about preserving.fill_color(STRING, default#FFFFFF, optional) - hex color for the padding.average_color(enumon/off, optional) - whether to compute the mean color.image(IMAGE, optional) andmask(MASK, optional) - the picture and an optional mask to carry through.
Outputs: image list (the resized result), average_image (a swatch of the mean color), average_hex (that color as a string - feed it back into fill_color for self-matching padding), and mask.
How to install it
Via ComfyUI Manager: search comfyui-mixlab-nodes, install, restart. Or clone the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/shadowcz007/comfyui-mixlab-nodes.git
then pip install -r requirements.txt (or install.bat on the Windows portable build) and restart. No model downloads for this one.
Common issues & troubleshooting
My image got padded when I wanted it stretched (or vice versa). That's the scale_option doing its job - different modes trade off "fill the box exactly" against "don't distort." If you want an exact fit with no padding and you don't mind distortion, that's a different mode than "fit and pad." Try each of the four and preview; the names are terse and it's faster to eyeball than to reason about.
The padding color clashes. Turn average_color on and route average_hex into fill_color. Now the padding is drawn from the image's own mean color instead of hard white, which reads far cleaner behind a generation.
Aspect ratio still looks off downstream. Remember the model cares about the final width/height you set here, not the original. If faces or proportions look squashed after generation, you probably picked a fit mode that distorts rather than pads - switch modes so the subject keeps its shape and the box gets padded instead.
Mask and image drift apart. If you're passing a mask through, it's resized alongside the image; feed the matching mask in, and use the output mask (not your original) downstream so the padded region is accounted for.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| width | INT | 5121–8192 | — |
| height | INT | 5121–8192 | — |
| scale_option | COMBO | 4 options: width, height, overall, center | |
| imageopt | IMAGE | — | |
| average_coloropt | COMBO | 2 options: on, off | |
| fill_coloropt | STRING | #FFFFFF | — |
| maskopt | MASK | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| image list | IMAGE | — |
| average_image | IMAGE | — |
| average_hex | STRING | — |
| mask | MASK | — |