PD:image_resize_custom
Exact-pixel resize that keeps your mask in lockstep
- pixels
- mask_optional
- IMAGE
- MASK
Most resize nodes in ComfyUI want a ratio plus a longest side, and that's usually the right way to think. But sometimes you have a hard number in your head - the VAE's 1024x1024, an exact tile size for a training batch, a fixed canvas you're compositing onto - and you just want it at those exact pixels. That's the niche PDImageResizeV3 ("PD:image_resize_custom") fills: you type a width, you type a height, and the image comes out precisely that size, with its mask resized alongside so you never get the image and alpha out of sync.
It's part of 7BEII/Comfyui_PDuse, a Chinese-authored utility pack ("PDuse") that bundles dozens of small image, text, and JSON helpers. This node is a heavier hammer than the core Image Resize, which is why it's worth knowing when to reach for it - and when to skip it.
How it works
The mechanism is a straightforward per-image loop: each frame in your batch gets the same treatment, so a whole batch comes out the same size instead of each frame doing its own thing. The crop_mode dropdown decides the strategy:
- crop - the image is scaled to cover the target and then cropped to exactly
target_width×target_height. Where the crop lands is yours to pick viahorizontal_align(left/center/right) andvertical_align(top/center/bottom). This is the "smart" mode; center-crop is the safe default. - stretch - forced resize, no cropping. The aspect ratio is ignored. Fine for a canvas you're pasting onto, but it will squish faces.
There's no "none"/keep-ratio mode in V3 - the README's older V2 had one. If you want longest-edge-with-ratio behavior, V3 is the wrong node; it's purpose-built for exact dimensions.
The inputs that matter
pixels- the IMAGE in.crop_mode- crop or stretch, described above.target_width/target_height- 64 to 8192, default 1024, steps of 8. Keep them multiples of 8; the node won't stop you, but downstream VAE nodes will be happier.mask_optional- a MASK input. Wire this up when you're resizing a transparent PNG. The pack's own docs spell out the gotcha: a transparent PNG run through a resize node without its mask comes out with a white or black halo where the alpha used to be. ConnectLoad Image.MASK→mask_optionaland the outputMASKstays faithful.
Outputs are IMAGE and MASK, both resized identically - that's the whole point, one node instead of a resize-plus-crop pair fighting each other.
Installing
ComfyUI Manager is the easy route: search for Comfyui_PDuse in the Custom Nodes tab. Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/7BEII/Comfyui_PDuse
cd Comfyui_PDuse
pip install -r requirements.txt
Then restart ComfyUI. The pack's real requirements are numpy, Pillow, torchvision, opencv-python, scipy, xlrd, openpyxl - you already have the first four from ComfyUI itself, so the new heavy one is scipy. There are no model downloads; this is a pure utility node.
Gotchas
Two, both inherited from the pack. First, the README is in Chinese (the author documents on a Feishu wiki and posts videos on bilibili), so don't expect English docs. Second, node naming is inconsistent across the pack - this one registers as "PD:image_resize_custom" even though the class is PDImageResizeV3, so searching for "resize" won't always find it. If you only need longest-edge scaling, the stock nodes do it with fewer clicks; grab V3 when exact pixels or batch-consistent masks actually matter.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| pixels | IMAGE | — | |
| crop_mode | COMBO | crop | 2 options: crop, stretch |
| target_width | INT | 102464–8192 | — |
| target_height | INT | 102464–8192 | — |
| horizontal_align | COMBO | center | 3 options: left, center, right |
| vertical_align | COMBO | center | 3 options: top, center, bottom |
| mask_optionalopt | MASK | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| MASK | MASK | — |