Nodes/ComfyUI-GTF-Utilities/Resampler | Area
ComfyUI Node

Resampler | Area

Shrink images without the moiré — the area-average filter

By wmpmiles·Created 2 years ago·Updated about a year ago· 5
Resampler | Area
    • resampler

    Resampler | Area is the downscaling specialist. Where every other filter in this pack decides each output pixel by sampling a handful of nearby input pixels, the area filter averages all the input pixels that fall inside each output pixel's footprint. It's the "pixel-perfect shrink" - the right answer whenever you're reducing an image and you don't want aliasing, moiré, or shimmering fine detail.

    It has no inputs, just a single resampler output to wire into Resample Image, Resample Mask, or Resample Latent. Add it, connect it, done.

    Why area-averaging matters for shrinking

    Here's the trap that catches people: use a sharp filter like Lanczos to downscale a photo and you get aliasing - the fine detail (fences, fabric weave, brick patterns) folds over itself into moiré patterns that weren't in the original. Use nearest-neighbor and you get chunky sampling noise. Area averaging sidesteps all of it by integrating the actual source pixels, which is why it's the classic answer to "I made this smaller and now it looks like a glitch." For downscales of roughly 1.5× or more, it's the filter to reach for, period.

    You can also use it for slight upscaling (say 1.1×) where it behaves like a gentle, safe average - but once you're genuinely enlarging, a sharp filter like Resampler | Lanczos or the balanced Resampler | Mitchell-Netravali will give you more detail. The shorthand: area to shrink, Lanczos to grow, Mitchell-Netravali when you want a safe middle.

    One note for the mask people: area-averaging a mask gives you a soft, anti-aliased edge, which is sometimes what you want (feathered composite) and sometimes not (hard selection). If the latter, Resampler | Nearest-Neighbor is your friend. The pack's own inpaint nodes keep these straight by using nearest-neighbor on masks internally.

    Setting it up

    Since it has no parameters, the only decisions live elsewhere: pick a scaler to define the target size (e.g. Scaler | Area with a multiplier of 0.25 to quarter the pixel count, or Scaler | Fixed for an exact resolution), wire both into a Resample Image, and the shrink is honest about its pixels. If you're in a downscaling-heavy workflow - preparing crops for a detail pass, building thumbnails, normalizing resolutions before a ControlNet - this is the resampler that belongs in the chain.

    Installing

    Part of comfyui-some-image-processing-stuff:

    cd ComfyUI/custom_nodes
    git clone https://github.com/wmpmiles/comfyui-some-image-processing-stuff
    

    Restart ComfyUI, or install via ComfyUI Manager (search "Some Image Processing Stuff"). No models, no extra dependencies - pure torch, so it installs as fast as a git clone. And the standing gotcha for the whole pack: a resampler that isn't wired into a Resample node is just sitting there looking pretty; the socket on the Resample node is required.

    Categoryresampling

    Inputs (0)

    No inputs

    Outputs (1)

    NameTypeDescription
    resamplerRESAMPLER