Nodes/ComfyUI-WJNodes/image scale pixel v2
ComfyUI Node

image scale pixel v2

Resize by target megapixels, the way Wan video actually wants it

By 807502278·Created 2 years ago·Updated 11 months ago· 21
image scale pixel v2
  • images
  • masks
  • option
  • image
  • mask
  • width
  • height
TotalPixels1.0486
alignment64(sd/kontext/wan)

Most resize nodes ask you for a width and a height. image_scale_pixel_v2 asks a more useful question for video work: how many total pixels do you want, and what multiple does the result need to be aligned to? That's the framing Wan video actually needs - the model cares about total pixel count for VRAM and speed, and it needs width/height locked to specific multiples depending on the mode you're running.

It's the core resize node in a small ratio-focused corner of ComfyUI-WJNodes, a big personal utility pack from GitHub user 807502278 that also covers cropping, video slicing, and color work.

How it works

TotalPixels is measured in millions of pixels, and the node description gives you a genuinely useful cheat sheet baked right into it: 0.32 ≈ a fake-720p target, 1 ≈ real 720p, 2 ≈ 1080p, 8.3 ≈ 4K. Pick the number that matches your target resolution class rather than doing the width×height math yourself. alignment then forces the output width and height to be a multiple of whichever value you pick - most Wan workflows want 64, but VACE and image-to-video variants specifically need 128, and the node spells that out right in the enum labels so you don't have to remember it. Images and masks scale independently of each other - connecting both doesn't force them to match sizes.

The inputs and outputs that matter

  • TotalPixels (default 1.0486, meaning just over 1 megapixel - roughly 720p territory) - your target pixel budget. This is the knob that actually controls how big the output is and how much VRAM the following steps will need.
  • alignment (default 64(sd/kontext/wan)) - the multiple the final width/height gets locked to. The enum labels tell you which model family expects which value: 64 covers SD/Kontext/most Wan, 128 is specifically called out for wan-vace/wan-i2v, and there's a 16(QwenImage) option too. Get this wrong and the model you feed it into may reject the input size outright.
  • images / masks (optional) - what actually gets resized. Leave either disconnected if you only need one.
  • option (optional, SO type) - plug in image_scale_pixel_option here for finer control over crop/fill/pad behavior, resample filter, and rounding. Skip it entirely and the node uses sensible built-in defaults.

Outputs: image, mask (the resized results), plus width and height as plain INT values - wire those straight into your EmptyLatentImage or sampler node so your latent matches exactly.

How to install it

Via ComfyUI Manager, search "ComfyUI-WJNodes." Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git

Restart ComfyUI. No model downloads needed - it's a resize node, not an inference node.

Common issues & troubleshooting

Wan (especially VACE or I2V) rejects your input size, or generation looks warped. Almost always an alignment mismatch - VACE and I2V variants need 128, not the 64 default. Check the alignment dropdown before assuming the problem is elsewhere in your workflow.

Output resolution is smaller or larger than you expected. Remember TotalPixels is in millions of pixels, not a direct width/height - use the built-in cheat sheet (0.32/1/2/8.3 for fake-720p/720p/1080p/4K) rather than guessing a raw number.

Ran out of VRAM anyway. TotalPixels is exactly the lever meant to prevent this - if you're still OOMing, bring the value down rather than fighting it with other settings; that's the whole point this node was built for, per its own description.

Image and mask come out different sizes and something downstream errors. That's expected - they scale independently. If a downstream node needs them to match, make sure both were fed a consistent size upstream, or resize them separately with matching settings.

No community reports for this exact node. It's part of a personal pack with no real public discussion, so lean on the general Wan-alignment knowledge above and test your resolution/alignment combination on one image before batching a whole run.

CategoryWJNode/ImageEdit/ratio

Inputs (5)

NameTypeDefaultDescription
TotalPixelsFLOAT1.04860–1024
alignmentCOMBO64(sd/kontext/wan)11 options: 1(No restrictions), 2, 4, 8, 16(QwenImage), 32, +5
imagesoptIMAGE
masksoptMASK
optionoptSO

Outputs (4)

NameTypeDescription
imageIMAGE
maskMASK
widthINT
heightINT