Nodes/Comfyui_PDuse/PD:image_resize_custom
ComfyUI Node

PD:image_resize_custom

Exact-pixel resize that keeps your mask in lockstep

By 7BEII·Created 2 years ago·Updated 15 days ago· 53
PD:image_resize_custom
  • pixels
  • mask_optional
  • IMAGE
  • MASK
crop_modecrop
target_width1024
target_height1024
horizontal_aligncenter
vertical_aligncenter

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 via horizontal_align (left/center/right) and vertical_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. Connect Load Image.MASKmask_optional and the output MASK stays 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.

CategoryPDuse/Image

Inputs (7)

NameTypeDefaultDescription
pixelsIMAGE
crop_modeCOMBOcrop2 options: crop, stretch
target_widthINT102464–8192
target_heightINT102464–8192
horizontal_alignCOMBOcenter3 options: left, center, right
vertical_alignCOMBOcenter3 options: top, center, bottom
mask_optionaloptMASK

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK