Nodes/Painting Coder Utils/Image Resolution Adjuster 📐
ComfyUI Node

Image Resolution Adjuster 📐

The node that forces your images onto an SDXL-friendly canvas — and gives you the mask to prove it

By jammyfu·Created 2 years ago·Updated about a year ago· 16
Image Resolution Adjuster 📐
  • images
  • images
  • mask
  • width
  • height
target_resolution
extend_mode
scale_factor1.0
max_width2048
max_height2048
min_width640
min_height640
background_color#000000
feathering40
invert_maskfalse
add_outlinefalse

The classic ComfyUI img2img trap: your input image is 817×603, your model was trained around 1024×1024, and the VAE decode comes back with warped anatomy or the model refuses to do what you asked. Image Resolution Adjuster is the fix for the "wrong canvas" problem - it resizes, pads, or crops your image onto a target SDXL aspect ratio, optionally fills the padding with a color, and - the genuinely useful part - hands you the mask of exactly where the new canvas isn't the original image, so you can inpaint the filled regions instead of leaving obvious seams.

It's the flagship node of the Painting Coder Utils pack, and the one the author clearly spent the most time on.

How it works

You pick a target_resolution from the SDXL optimal list (plus the Midjourney-style extras) and an extend_mode, and the node resizes your image to fit:

  • contain / inside - fit the whole image inside the canvas, padding the leftover space with background_color (default #000000). inside only shrinks.
  • cover / outside - scale to cover the canvas, cropping the overflow. outside only grows.
  • fill - stretch to fill, distorting the aspect ratio if needed.
  • top / bottom / left / right / center - pad the image toward one edge (no resizing), with the background color filling the rest.

Then it outputs a mask marking the padded regions (white = padding, black = original content). That mask is the key to the pack's own recommended workflow: run the padded image through a batch inpaint so the filled areas get painted to match, instead of left as flat black bars. The feathering control (default 40) softens the mask edge so the inpaint blends instead of showing a hard boundary, and add_outline adds a one-pixel contrast outline around the image - handy when the background color matches the image edge.

Also worth knowing: scale_factor multiplies the target size, and max_width / max_height / min_width / min_height (defaults 2048/2048/640/640) clamp the result so a careless multiplier can't send you to a 12K canvas.

Inputs and output

  • images - the IMAGE(s) to adjust.
  • target_resolution, extend_mode, scale_factor, the four size clamps, background_color (hex like #000000), feathering, invert_mask, add_outline.
  • Outputs: images (the adjusted image), mask (padding mask, optionally inverted), width, height (the resulting canvas size).

Where you'll use it

Img2img and inpainting chains where the source image's aspect ratio fights the model; batch workflows (the README shows a Flux batch-inpainting example) where every image needs to land on the same canvas; and outpainting setups where you intentionally want a bigger canvas plus the mask to fill it. The mask output is what separates this from a plain resize - you're not just rescaling, you're setting up the next step.

Install

ComfyUI Manager → Painting Coder Utils, or:

cd ComfyUI/custom_nodes
git clone https://github.com/jammyfu/ComfyUI_PaintingCoderUtils.git

Restart ComfyUI. No models or keys anywhere in this pack; dependencies (numpy, Pillow, torch, gradio) are already present. One caution the author flags: v0.3.0 renamed the namespace, so old workflows stop resolving these nodes - use the bundled docs/fix/workflow_fixer.html to repair inherited JSON.

Category🎨Painting👓Coder/🖼️Image

Inputs (12)

NameTypeDefaultDescription
imagesIMAGE
target_resolutionCOMBO19 options: 5:12 (640x1536), 1:2 (768x1536), 9:16 (816x1456), 4:7 (768x1344), 2:3 (896x1344), 2:3 (832x1216), +13
extend_modeCOMBO10 options: contain, cover, fill, inside, outside, top, +4
scale_factorFLOAT1.00.1–10
max_widthINT20481–8192
max_heightINT20481–8192
min_widthINT6401–8192
min_heightINT6401–8192
background_colorSTRING#000000
featheringINT400–512
invert_maskBOOLEANfalse
add_outlineBOOLEANfalse

Outputs (4)

NameTypeDescription
imagesIMAGE
maskMASK
widthINT
heightINT