Nodes/ComfyUI-Non-offset/Smart Resize & Pad (Edge Pixel)
ComfyUI Node

Smart Resize & Pad (Edge Pixel)

The Qwen-Edit padding that doesn't poison attention

By starsFriday·Created 10 months ago·Updated 10 months ago· 0
Smart Resize & Pad (Edge Pixel)
  • image
  • padded_image
  • mask
◄target_size1024►

The name is doing real work here: "Smart Resize & Pad (Edge Pixel)" is the version of this pack you should probably be using. Qwen-Image-Edit-2511 fixed a lot of the drift the original model was famous for, but it still wants a square input, and the obvious way to get one - slapping black bars on the short side - turned out to be part of the problem. Hard edges between pure-black padding and real pixels mess with the model's positional embeddings, and big zero-valued regions dilute the valid features during self-attention. The author of ComfyUI-Non-offset measured exactly this in their own 2509/2511 tests: a few to tens of pixels of positional drift that came straight from the padding.

V2's trick is to pad with edge replication instead. Instead of filling the short side with zeros, it stretches the image's own edge pixels outward, so the padding region looks visually continuous with the original. The model gets its clean square canvas without being handed a giant black rectangle to be distracted by.

How it works

Under the hood it's the sibling of the pack's V1 node, with one line changed. The image is resized proportionally (bilinear) so the long side matches target_size, then the short side is padded with PyTorch's replicate mode instead of a constant zero. Portrait images get left padding, landscape get top padding. The node returns two outputs:

  • padded_image - the square frame with edge-replicated filler.
  • mask - white where the original pixels are, black where the padding is.

That mask is your escape hatch. Because the padding is replicated texture rather than black, it can occasionally read as "content" to the model and show up as smeared edges in the final render. If that happens, composite the edit back onto the original using the mask so the padding never appears in your output.

Inputs

Just two, and the defaults are right:

  • image - the IMAGE tensor to prepare for the editor.
  • target_size - square canvas size, default 1024, min 64, max 8192, step 8. The README's tip is that at 1024×1024, qwen-edit handles bounding boxes and point guidance most reliably - keep it there unless you have a reason not to.

Install

Same pack as V1, so installing once gets you both: search ComfyUI-Non-offset in ComfyUI Manager, or:

cd ComfyUI/custom_nodes
git clone https://github.com/starsFriday/ComfyUI-Non-offset.git

Restart ComfyUI. No dependencies beyond torch and no model downloads - requirements.txt is empty for good reason.

Which one should you use?

The pack's own guidance: V1 (black padding) for qwen-edit-2509, V2 (edge replication) for qwen-edit-2511. If you're on the newer model, just reach for V2 by default - it's the variant that exists specifically because black borders caused drift in the 2509/2511 series. V1 isn't dead weight; it's the faithful "letterbox" behavior some 2509 setups expect. But this is a case where the improved version isn't a marketing gimmick - it directly addresses the failure mode its predecessor could cause. Start with V2, keep the mask wired out, and only fall back to black padding if a workflow demands it.

CategoryCustom/ImageProcessing

Inputs (2)

NameTypeDefaultDescription
imageIMAGE—
target_sizeINT102464–8192—

Outputs (2)

NameTypeDescription
padded_imageIMAGE—
maskMASK—