PDImageResize
PDImageResize — the Swiss-army resize with stretch, pad, crop, and a 8x safety
- image
- IMAGE
- width
- height
Core ComfyUI's ImageScale will stretch an image to any size you ask, ratio be damned. PDImageResize is the node for when "any size" isn't good enough - it gives you four distinct resize behaviors, interpolation choices, an optional multiple_of constraint to keep dimensions latent-friendly, and it hands back the final width and height so the rest of your graph knows what actually happened.
If you've ever resized a batch and then discovered the images came out 1022×1026 instead of 1024×1024 (and your model grumbled), this node's multiple_of is the thing you didn't know you wanted.
The four methods (the part that matters)
- stretch - force to exactly
width×height. Distorts the aspect ratio. There are better nodes for most jobs, but sometimes you genuinely want the distortion. - longest size - landscape images scale to
width(height follows), portrait scale toheight(width follows). The aspect-ratio-preserving default for most use. - fill / crop - scale up so the image covers the target, then center-crop the overflow. This is the "cover" behavior you know from CSS and social platforms: no distortion, no empty bars, but content gets cut.
- pad - scale to fit inside the target, then pad the leftover space with black to hit
width×heightexactly.
On top of that, multiple_of (default 0 = off) rounds the target dims down to a multiple of your number - set 8 and you're guaranteed 1024, not 1022. This is the knob that keeps VAE and latent paths happy, and it's worth turning on by default.
The inputs that matter
- image (
IMAGE) - source. - width / height (
INT, default 512) - target. 0 means "keep original" for that axis. - interpolation -
nearest/bilinear/bicubic/area/lanczos(defaults to bilinear in code; for upscaling preferlanczos, for downscalingarea). - method - one of the four above.
- multiple_of (
INT, default 0) - force output dims to a multiple of this.
Outputs: IMAGE, plus width (INT) and height (INT) - the actual output size, which differs from your request whenever longest size/pad/multiple_of adjust things. Wiring those back out is the tidy part: you can read the real dims for a filename or downstream sizing instead of guessing.
Where it fits
Standardizing batches for model input is the headline job: pick pad + multiple_of=8 and every frame comes out exactly 1024×1024 with ratio intact and bars added. Social-platform covers, thumbnail grids, and "make everything fit this box" jobs are its natural territory. lanczos is the interpolation to reach for when you're upscaling and quality matters; area when you're shrinking a 4K render down.
Gotchas
The longest size semantics are subtle: it uses width for landscapes and height for portraits, so if you set width=1024, height=1024, a 2:1 image becomes 1024×512 and a 1:2 becomes 512×1024. That's usually what people want, but if you expected both to be 1024 on their long edge, you'd actually want PDIMAGE_LongerSize. And the pad mode always pads with black - if you need a configurable background color, PDImageResizeV2's letterbox fit has a background_color input for that.
Install
ComfyUI Manager: search PDuse (repo 7BEII/Comfyui_PDuse), install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt
Restart and it appears as PDImageResize under PDuse/Image. Four behaviors, real output dims, and a multiples safety - the workhorse resize.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| width | INT | 5120–8192 | — |
| height | INT | 5120–8192 | — |
| interpolation | COMBO | 5 options: nearest, bilinear, bicubic, area, lanczos | |
| method | COMBO | 4 options: stretch, longest size, fill / crop, pad | |
| multiple_of | INT | 00–512 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| width | INT | — |
| height | INT | — |