PD:banana imagesize by ratio
Banana imagesize by ratio: shove any image into an SDXL-era size bucket
- image
- image
PD:banana imagesize by ratio (PDbananaImagesizeByRatio) resizes an image to one of eight preset size-and-ratio buckets - 1:1 at 1024, 4:3 at 1184×864, 16:9 at 1344×768, and so on - and decides what to do with the mismatch: crop, pad, or stretch. It's a one-node answer to "make this image exactly this aspect ratio at exactly this resolution," which in 2026 is a surprisingly recurring request because those presets are exactly the size buckets the SDXL-era latent models were trained on.
How it works
You pick a preset_size, and the node scales the image to fit. The interesting part is resize_mode, which determines how it handles the aspect mismatch:
crop- scales up until the image covers the target, then crops the overflow. Nothing lost is nothing... well, content is lost at the edges.pad(default) - scales to fit inside the target and fills the letterbox with thepadding_color.stretch- just force-resizes, aspect ratio be damned. Almost always the wrong choice unless the distortion is acceptable.
image_location (top/down/left/right/center) picks where the image sits in the crop window or the padded canvas. padding_color is where it gets fun: black, white, or noise. The noise option is a genuinely thoughtful touch for training data - a noisy pad is less likely to be learned as a feature than a flat black bar. All scaling is Lanczos, and the output is a clean RGB tensor at exactly the target dimensions.
The inputs that matter
preset_size- the bucket. The dropdown carries both ratio and pixels, so what you see is what you get.resize_mode- crop vs pad vs stretch. This is the decision that shapes your output.image_location- where content sits after the transform.padding_color- black/white/noise. Pick noise for training sets, black/white for clean presentation.
Installing
Part of the 7BEII/Comfyui_PDuse pack. ComfyUI Manager → search "Comfyui_PDuse" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt
Restart after. No models to download; the dependencies are the pack's usual Pillow/numpy set.
Gotchas
The presets are fixed - there's no custom-size input, so if you need 768×1152 you're out of luck with this node; it's presets or nothing. And remember stretch doesn't preserve aspect ratio, which catches people who reach for it expecting a simple resize. If you're feeding a batch of images, note the node squeezes a batch dimension - it expects a single image tensor, so loop your batch through it or feed frames one at a time. For dataset prep it's the noise-pad option that makes it worth having in the toolbox.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| preset_size | COMBO | 4:3 (1184x864) | 8 options: 1:1 (1024x1024), 4:3 (1184x864), 3:4 (864x1184), 3:2 (1216x832), 2:3 (832x1248), 12:5 (1248x832), +2 |
| resize_mode | COMBO | pad | 3 options: crop, pad, stretch |
| image_location | COMBO | center | 5 options: top, down, left, right, center |
| padding_color | COMBO | black | 3 options: black, white, noise |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |