Nodes/comfyui-mixlab-nodes/Resize Image ♾️Mixlab
ComfyUI Node Runs on cloud

Resize Image ♾️Mixlab

Resize, pad, and grab the average color in one node

By MixLabPro·Created 3 years ago·Updated 2 months ago· 1,859
Resize Image ♾️Mixlab
  • image
  • mask
  • image list
  • average_image
  • average_hex
  • mask
width512
height512
scale_option
average_color
fill_color#FFFFFF

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, or center. 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 (enum on/off, optional) - whether to compute the mean color.
  • image (IMAGE, optional) and mask (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.

Category♾️Mixlab/Image

Inputs (7)

NameTypeDefaultDescription
widthINT5121–8192
heightINT5121–8192
scale_optionCOMBO4 options: width, height, overall, center
imageoptIMAGE
average_coloroptCOMBO2 options: on, off
fill_coloroptSTRING#FFFFFF
maskoptMASK

Outputs (4)

NameTypeDescription
image listIMAGE
average_imageIMAGE
average_hexSTRING
maskMASK