Papcorns - Aspect Resize
Papcorns Aspect Resize
- image
- image
Every ComfyUI user hits this wall eventually: your SDXL checkpoint wants 1024x1024, your video out wants 1216x704, and the image you actually produced is a different shape entirely. Resize it naively and people come out looking like they swallowed a car. The classic answer is a chain - scale, then crop or letterbox by hand, two or three nodes doing half a job each. Papcorns - Aspect Resize collapses all of that into one node with a mode switch. It doesn't do anything a multi-node rig can't, but it does it in one place, with the padding and cropping handled for you.
What it actually does
Give it an image and a target width and height, pick a mode, and it returns an image at exactly that size with the aspect ratio respected. Under the hood it converts the ComfyUI tensor to PIL, resizes with LANCZOS (good quality, not the cheapest), and runs one of two algorithms:
aspect_fill- zooms in far enough that the source covers the whole target, then center-crops. You lose the edges, never the center. This is the mode for "I need this region to fill the frame."aspect_fit- scales down to fit inside the target, then pads the leftover space so the output is still the exact size you asked for. Choosepadding_colorblackorwhitefor the bars.
That's the whole mechanism. Fill = max scale factor + crop; fit = min scale factor + centered pad. Both end at your exact target dimensions.
The inputs that matter
Only four of them, and you'll touch most every run:
image- any IMAGE tensor, straight out of a VAE decode.width/height- default 640 each, range 64–8192 in steps of 8. The step of 8 keeps you on the multiples diffusion and most video encoders like, so you're not fighting resolution errors downstream.mode- theaspect_fill/aspect_fitswitch described above.padding_color- only consulted in fit mode; black or white.
The single output is image, which wires into anything that expects an IMAGE - a Save Image node, an encoder, a ControlNet preprocessor input. One wire in, one wire out, nothing clever.
Where it earns its place
Honestly, the most common use is nailing exact output sizes: generating at a model's native ratio (KB advice: for 16:9, generate near 7:4, then crop to 1080p - don't ask SDXL to draw 1920x1080) and using aspect_fit to letterbox a generated frame into a video pipeline's strict resolution, or aspect_fill when a ControlNet region needs to be exactly square. It's also handy in batch workflows where every image in the stack needs to be the same shape before you stack them.
Install
It ships in the Papcorns pack, so install once for the whole family:
cd ComfyUI/custom_nodes
git clone https://github.com/papcorns/Papcorns-Comfyui-Custom-Nodes
cd Papcorns-Comfyui-Custom-Nodes
pip install -r requirements.txt
Then restart ComfyUI. ComfyUI Manager can also find it - search for "Papcorns". No models to download; this is pure image math.
Gotchas
- It's a resizer, not a detail regenerator. LANCZOS upscaling 2x will look soft, same as any single-pass upscale. If you want to grow an image, generate big then use fill-crop to trim - don't use this node as your upscaler.
- Only black or white padding. If you need a blurred or transparent bar (common for video), fit mode won't get you there - pad yourself.
- It's a small personal pack with a lightly-tested feel; the README only documents two of its seven nodes, so treat behavior you can't see in the UI as "read the source if it misbehaves."
For a node that does one thing, it does it cleanly. When you're sick of the three-node stretch-and-pad dance, this is the one to reach for.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 64064–8192 | — |
| height | INT | 64064–8192 | — |
| mode | COMBO | aspect_fill | 2 options: aspect_fill, aspect_fit |
| padding_color | COMBO | black | 2 options: black, white |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |