FFT-Based Resize (Crop)
Resize in frequency space and see exactly what resampling does
- frequency
- frequency
FFT-Based Resize (Crop) resizes an image by working on its spectrum instead of its pixels. It takes a FREQUENCY, crops or zero-pads the spectrum to a new height and width, and hands back a resized FREQUENCY that ImageIFFT2D turns into pixels. If you've ever wondered what "ideal resampling" actually means, this node is the demonstration: it's the mathematically cleanest resize that exists, and it's also a perfect illustration of why "cleanest" doesn't mean "best looking."
Here's the deal in one line: in frequency space, cropping the spectrum = downsampling (you throw away the highest frequencies, which is exactly what a proper anti-aliasing filter does before you decimate), and zero-padding the spectrum = upsampling (you add empty high frequencies, which is what ideal sinc interpolation does). The "(Crop)" in the name is because the upsample path zero-pads, the downsample path crops.
The two resizes and what they cost you
Downsizing is genuinely clean - an ideal low-pass-then-decimate with no aliasing. This is frequency-domain resizing at its best, and it's why people doing FFT work reach for this node to shrink a spectrum properly.
Upsizing is where you need to set expectations. Zero-padding adds silent frequencies - the original image had no energy up there, so the upscaled result is smooth, slightly soft, and can ring with faint halos near sharp edges. That ringing is the signature of ideal sinc interpolation, and it's the same tradeoff the KB's upscaling essay flags for the whole "more pixels" category: this adds no content, cannot hallucinate, runs in milliseconds. It will not invent detail. Next to a 4x ESRGAN model or a generative upscaler, FFT upscaling looks soft by comparison - but it's also impossible for it to invent anything, which is sometimes exactly the point. For a spectrum that needs to stay a spectrum at a new size - say you're aligning two images' FFTs for comparison - this node is the correct tool and no pixel-domain resampler will do.
The brightness detail
There's a subtle bug the node quietly fixes for you. np.fft.ifft2 divides by the total pixel count, so simply cropping or padding a spectrum changes the reconstructed image's brightness. This node rescales the spectrum by (new_area / old_area) to compensate, so the output of ImageIFFT2D keeps the same average brightness as the original. Nice - that's the kind of thing that would have cost you an hour of "why is my image darker now" debugging otherwise.
Inputs are frequency, new_height, and new_width (both 1–8192). Output is a resized frequency.
How to install it
Standard for the pack. ComfyUI Manager → search ComfyUI-FFT-2D → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/NobutakaKuroki/ComfyUI-FFT-2D
Restart ComfyUI. No pip extras, no model downloads - it's CPU numpy under the hood, so an 8K resize will take a moment but a 512→1024 is instant. lesson_workflows/2_FFT_BasedResize.json is the intended walkthrough, and this is Dr. Nobutaka Kuroki's educational pack, so treat it as a way to see what resampling does rather than a replacement for your favorite upscaler.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| frequency | FREQUENCY | — | |
| new_height | INT | 5121–8192 | — |
| new_width | INT | 5121–8192 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| frequency | FREQUENCY | — |