ComfyUI Node

Image Scale

Scale an image and its mask together to a target size. Pick by-long-side, by-short-side or a custom size, then stretch, crop, fill with a colour / border colour / edge pixels, or fit a total pixel count. Interpolation, anchor, a run condition, the fill colour and a multiple-of rounding are all adjustable. Both image and mask are optional but at least one has to be connected; a mask alone outputs a black placeholder image. The returned width and height feed straight into size inputs, and every parameter lines up with Goohaitools Image Scale V2 so the same numbers can be pasted between the two nodes.

By live1617·Created about a month ago·Updated a day ago· 4
Image Scale
  • image
  • mask
  • image
  • width
  • height
  • mask
◄width512►
◄height512►
◄scale_methodby-long-side►
◄edge_size1024►
◄interpolationlanczos►
◄scale_modecrop►
◄anchorcenter►
◄conditionalways►
◄fill_color#364254►
◄multiple_of0►
CategoryQG-tools/Image

Inputs (12)

NameTypeDefaultDescription
widthINT5120–100000Target width in custom-size mode; 0 derives it from the height. Ignored by the by-long-side / by-short-side methods.
heightINT5120–100000Target height in custom-size mode; 0 derives it from the width. Ignored by the by-long-side / by-short-side methods.
scale_methodCOMBOby-long-sideby-long-side / by-short-side: apply the edge length below to the long or the short side. custom-size: use the width and height above.
edge_sizeINT102464–100000Target edge length in pixels for the proportional methods (1024 in the original node). Also used by the when-long-side-greater / when-short-side-smaller conditions.
interpolationCOMBOlanczosResampling filter. The image and the mask are resampled with the same filter, matching Goohaitools Image Scale V2.
scale_modeCOMBOcropstretch / crop / three fill modes / total pixels. Note: with by-long-side or by-short-side and multiple_of <= 1 this is not used at all (the original node behaves the same way).
anchorCOMBOcenterWhich side survives a crop or a fill: center / top / bottom / left / right.
conditionCOMBOalwaysRun always, or only when the long side is greater / the short side is smaller than the target. Otherwise the input passes through unchanged (multiple_of may still adapt the size).
fill_colorSTRING#364254Canvas colour for the fill-color mode, as #RRGGBB (default #364254). Click the swatch on the node to pick one or type the hex; the original node writes the same string.
multiple_ofINT00–256Round the final width and height up to a multiple of this number (0 or 1 means no rounding). Each scale mode rounds in its own direction, matching the original node.
imageoptIMAGEThe image batch to scale, standard [B,H,W,C]. Optional: with only a mask connected the image output is a black placeholder.
maskoptMASKThe mask to scale together with the image. Not connected gives an all-black mask; a single frame is repeated to match a multi-frame image.

Outputs (4)

NameTypeDescription
imageIMAGE—
widthINT—
heightINT—
maskMASK—