Nodes/ComfyUI-PepeUtils/Pepe Resize Image
ComfyUI Node

Pepe Resize Image

The one node for resize, pad, crop and pillarbox — without wrecking the pixels

By Pepehoschi·Created 5 months ago·Updated 12 days ago· 0
Pepe Resize Image
  • image
  • mask
  • image
  • width
  • height
  • mask
width1024
height1024
keep_proportionresize
pad_color_r0
pad_color_g0
pad_color_b0
crop_positioncenter
divisible_by8

ComfyUI's built-in resize is thin, and its downscaling quality is a known sore spot - plain bilinear and bicubic turn to mush on clean line art, and Lanczos oversharpens and halos. Pepe Resize Image is the "just resize it properly" node. It bundles every geometry mode you'd want - stretch, proportional resize, pad, crop, and even a pillarbox-blur background - into one node, and it picks a genuinely good resampler automatically: Lanczos when enlarging, and a Photoshop-style Bicubic Sharper approximation when shrinking.

Think of it as the KJNodes-style utility you keep reaching for, minus the parts that make you wire three nodes together. You give it a target size, it gives you a result that's aligned to a stride you choose and, if you pass one in, a mask resized to match.

How it works

The node takes your requested width and height and runs them through a small geometry engine:

  • width or height of 0 means "derive this from the source aspect ratio" - give it 0 × 768 and you get a proportional 768-tall version, no mental math.
  • Everything is aligned downward to divisible_by (default 8), which keeps output dimensions friendly for latents and VAE decode.
  • The resampler is chosen per direction: Lanczos (common_upscale) for enlargements, and the Pepe Bicubic Sharper path (from the sibling Pepe Scale Image By node) for reductions. Mixed-axis cases shrink first, then enlarge, so the expensive upscale doesn't fight a downscale.

The keep_proportion dropdown is where the modes live, and they behave like the names say: stretch forces the exact size; resize scales to fit while keeping aspect; pad centers it on a solid-color canvas; pad_edge fills the bars with the image's average edge colors; pad_edge_pixel replicates actual edge pixels; crop scales to cover and trims with a crop_position (center/top/bottom/left/right); pillarbox_blur puts a blurred, cover-fit version of the image behind a sharp fitted foreground - the classic video-frame look; total_pixels hits an exact megapixel budget (width × height) while keeping aspect.

Optional mask rides along with the same geometry, resized with bilinear interpolation and pasted into the same canvas, so mask and image never disagree.

Inputs and outputs

The inputs that matter for most workflows: image, width, height, keep_proportion, divisible_by, and the three pad_color_r/g/b values (0–255) when you're padding. The crop_position matters for crop and for where the fitted content sits in pad modes.

Outputs are image, width, height (the actual aligned dimensions - handy to wire into a downstream Empty Latent Image), and mask.

Installing it

Pepe Resize Image ships in Pepehoschi/ComfyUI-PepeUtils (GPL-3.0). Install via ComfyUI Manager (search "ComfyUI-PepeUtils") or:

cd ComfyUI/custom_nodes
git clone https://github.com/Pepehoschi/ComfyUI-PepeUtils

Restart ComfyUI. No extra dependencies - just the torch/numpy/Pillow stack ComfyUI already ships.

Where it's slow, and where it shines

The Bicubic Sharper path runs on CPU via a NumPy resampler, so very large images or batches resize slower than ComfyUI's GPU scaling would. Fine for single frames and typical img2img prep; not the node for bulk-processing 4K batches. On the flip side, that CPU path is exactly why the downscale looks better - the same reason people keep complaining that Comfy's built-in downscale halos on line art. For clean geometric output, pad_edge_pixel is a genuinely nice touch: it fills bars with the actual edge pixels instead of a flat color, which reads much better on illustrations. Set width or height to 0 when you want aspect-ratio-safe resizes, and you'll rarely have to think about geometry again.

Categoryutils/image

Inputs (10)

NameTypeDefaultDescription
imageIMAGE
widthINT1024
heightINT1024
keep_proportionCOMBOresize8 options: stretch, resize, pad, pad_edge, pad_edge_pixel, crop, +2
pad_color_rINT00–255
pad_color_gINT00–255
pad_color_bINT00–255
crop_positionCOMBOcenter5 options: center, top, bottom, left, right
divisible_byINT8
maskoptMASK

Outputs (4)

NameTypeDescription
imageIMAGE
widthINT
heightINT
maskMASK