Nodes/ComfyUI-WJNodes/Composite Scale
ComfyUI Node

Composite Scale

Fit, cover, or stretch your layer to the canvas

By 807502278·Created 2 years ago·Updated 11 months ago· 21
Composite Scale
  • Options
  • Composite_Basic
scale_X1.000
scale_Y1.000
ScaleMethodlong
ConditionalScaleNotUsed

The auto-fit sizing node in WJNodes' options-chain family for its ImageCompositeMask_adv compositor (Composite_Basic explains the chaining pattern the whole family shares). Where Composite_Coordinate gives you a flat scale multiplier, Composite_Scale gives you aspect-ratio-aware fitting logic - the same set of ideas web developers know as object-fit: contain versus cover versus fill, just under different names.

How it works

ScaleMethod is the whole node, really:

  • DoNot_AutoScale - no automatic scaling; use this if you're driving size purely through Composite_Coordinate's manual scale instead.
  • long (the default) - scales the surface so its longer edge fits inside the background, preserving aspect ratio. The classic "contain" behavior: the whole layer is visible, but there may be empty space on the shorter axis.
  • long_fill - same long-edge fit, but the shorter edge gets filled out to cover the full canvas rather than leaving a gap.
  • short - scales so the shorter edge fits the background instead, which means the longer edge can overflow past the canvas.
  • short_crop - same short-edge fit, but crops away whatever overflows on the longer edge. This is "cover" behavior: the canvas is fully filled, some of the layer gets cut off.
  • stretch - forces the surface to exactly match the background's dimensions, aspect ratio be damned. This is "fill," and it will distort a layer whose proportions don't match the canvas.
  • average - scales by the average of the width and height ratios between surface and background, a middle-ground compromise between long and short.

ConditionalScale adds a guard rail on top of whichever method you picked: NotUsed (default, always scale), max_if (only scale when the surface would actually need to grow), or min_if (only scale when it would need to shrink). That's the setting for "don't upscale a layer that's already bigger than the canvas" or its mirror image, without you having to branch your graph.

The inputs and outputs that matter

  • scale_X, scale_Y (default 1, range 0.01–2048) - extra manual multipliers layered on top of whatever the auto-fit method computes.
  • ScaleMethod (default long) - the fit strategy, from the list above.
  • ConditionalScale (default NotUsed) - whether scaling only kicks in for growth or shrink cases.
  • Options (optional) - the chain to extend.
  • Composite_Basic (output) - the updated chain.

Installing it

Via ComfyUI Manager: search ComfyUI-WJNodes, install, restart. Or:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git
cd ComfyUI-WJNodes
pip install -r requirements.txt

Nothing extra needed for this node.

Common issues & troubleshooting

Layer overflows the canvas or gets cropped unexpectedly. That's the difference between long/long_fill (never overflow) and short/short_crop (may overflow, second one crops it). If you don't want any part of your layer cut off, long or long_fill are the safe picks; short_crop is exactly what you want when you need the canvas fully covered and don't mind losing some edges.

Layer looks stretched or distorted. Check ScaleMethod isn't set to stretch unless you actually want that - it's the one method in this list that deliberately ignores aspect ratio.

Small layer got upscaled when you didn't want it to. Set ConditionalScale to min_if - that restricts scaling to shrink-only cases, so an already-small layer gets left alone instead of blown up to fill the canvas.

Manual scale_X/scale_Y seem to do nothing. They're multipliers applied on top of whatever ScaleMethod already computed, not a replacement for it - if ScaleMethod is DoNot_AutoScale, these become the only scaling in effect; otherwise they compound with the auto-fit result, which can be surprising if you expected them to act alone.

CategoryWJNode/ImageBlend/options

Inputs (5)

NameTypeDefaultDescription
scale_XFLOAT1.0000.01–2048
scale_YFLOAT1.0000.01–2048
ScaleMethodCOMBOlong7 options: DoNot_AutoScale, long, long_fill, short, short_crop, stretch, +1
ConditionalScaleCOMBONotUsed3 options: NotUsed, max_if, min_if
OptionsoptComposite_Basic

Outputs (1)

NameTypeDescription
Composite_BasicComposite_Basic