ComfyUI Node

HT Scale By

Scale an image and its mask together — HT Scale By

By ArtHommage·Created 2 years ago·Updated about a year ago· 4
HT Scale By
  • image
  • mask
  • scaled_image
  • scaled_mask
scale_factor1.00
interpolationbicubic
crop_to_maskfalse
mask_interpolationnearest

Lots of ComfyUI nodes can resize an image. Far fewer resize the image and its mask in lockstep, which is exactly the situation that shows up the moment you're doing mask-guided work: you crop or upscale the image, and suddenly the mask doesn't line up anymore. HT Scale By (from the HommageTools pack) handles both at once, with a factor-based scale (0.1×–8×), your choice of interpolation, and an optional crop-to-mask mode.

How it works

You give it an image and a scale_factor. It checks the tensor is proper BHWC (the pack's whole identity is "handles BHWC correctly"), computes the target dimensions, and resizes with PyTorch's interpolation. Which interpolation matters:

  • bilinear / bicubic - smooth results, with antialiasing applied. Your defaults for upscaling.
  • nearest - blocky, but right for masks you don't want fuzzed out.
  • area - good for downscaling, averages pixels.
  • lanczos - here's an honest quirk: the source maps lanczos to bicubic internally, so it's not a true Lanczos kernel. If you specifically wanted Lanczos, use the stock resize node instead; this one's a "close enough" for most cases.

If you pass a mask, it comes out scaled too, through the mask_interpolation setting (default nearest - correct choice for masks, since blurring a mask gives you soft semi-transparent edges you often don't want).

crop_to_mask is the standout: turn it on, and before scaling it finds the bounding box of non-zero pixels in the mask, crops both image and mask to that region, then scales. Net effect: "zoom into the masked subject and upscale just that." That's the standard trick for face/object work - crop tight, upscale, run a detailer on the region.

The inputs that matter

  • scale_factor - the whole point. 2.0 doubles the size, 0.5 halves it.
  • crop_to_mask - with a mask connected, this becomes a region-focused scale.
  • mask / mask_interpolation - only needed if you're scaling masks.

Outputs: scaled_image and scaled_mask, both BHWC, ready to feed straight into whatever comes next - a KSampler, a VAE encode, a compositing node.

Installing it

HommageTools install, once:

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

Restart, or use ComfyUI Manager → search "HommageTools". No models to download for this node. The pack is self-described as perpetual alpha, so treat it as a helper, not infrastructure.

Where it bites

The biggest gotcha is the missing divisibility check. Scale 2.0 on a 785×503 image gives you 1570×1006 - neither a multiple of 64, and even multiples of 8 are iffy. If that output goes into a VAE encode or a latent-based sampler that wants clean multiples, you'll get an error or a slightly-off latent. Snap the result to a multiple (or pair it with a resolution-snap node) when the downstream cares. And remember the Lanczos caveat above - if you genuinely need Lanczos quality, this node isn't delivering it, it's bicubic in a fancy coat.

CategoryHommageTools/Image

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
scale_factorFLOAT1.000.1–8
interpolationCOMBObicubic5 options: nearest, bilinear, bicubic, area, lanczos
crop_to_maskBOOLEANfalse
maskoptMASK
mask_interpolationoptCOMBOnearest5 options: nearest, bilinear, bicubic, area, lanczos

Outputs (2)

NameTypeDescription
scaled_imageIMAGE
scaled_maskMASK