Resampler | Nearest-Neighbor
Pixel-perfect resizing, for masks and pixel art only
- resampler
Resampler | Nearest-Neighbor is the no-filter filter: each output pixel just copies the closest input pixel. It's the fastest resampling method that exists and the only one with zero smoothing, and it has exactly two good use cases - masks and pixel art. It's also the only resampler in this pack with no inputs at all. You drop it on the canvas and its single output, a resampler wire, is ready to plug into Resample Mask, Resample Image, or Resample Latent.
Why you'd want the ugly option
Resampling a mask is the big one. Masks are selections, not photographs, and a "good" filter on a mask is usually a bad thing: Lanczos or Mitchell will smear the boundary into a gradient of intermediate gray values, and a soft mask edge is exactly how inpaint seams happen. Nearest-neighbor keeps a hard selection hard at any size. This pack's own inpaint nodes follow the same rule - Mask-Crop Inpaint | Pre resizes its masks with nearest-neighbor even while it resamples the image with your filter of choice. If you're resizing a mask and you see blurry edges, you grabbed the wrong resampler.
The second use is pixel art and any image with a deliberately blocky aesthetic, where "correct" interpolation ruins the art. And there's a niche third: when you're resizing to an exact integer multiple and want zero aliasing from the resample itself - though for genuine downscaling of real photos you don't want this at all.
What it does badly
Anything with continuous tone. Upscale a photo with nearest-neighbor and you get chunky stairsteps; downscale and you get aliasing, moiré, and dropped detail because it samples rather than averages. For photographs, Resampler | Lanczos for upscaling and Resampler | Area for downscaling are the ones you want. This node isn't broken - it's just telling you, honestly, what nearest-neighbor is for.
Wiring it up
Since it has no inputs, setup is trivial: add it, add a Resample Mask (or Image), add a scaler like Scaler | Fixed, and wire the resampler into the Resample node. One note: nearest-neighbor and Resample Latent is a combination you almost never want - latents are continuous by nature, and pixel-stairstepping a latent is asking for blocky generations. Keep it on the mask and pixel-art paths.
Installing
It's 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 find "Some Image Processing Stuff" in ComfyUI Manager. No dependencies, no model downloads - it's pure torch. The whole pack installs in one clone, so once this node is visible the other 19 are too.
Inputs (0)
No inputs
Outputs (1)
| Name | Type | Description |
|---|---|---|
| resampler | RESAMPLER | — |