Nodes/ComfyUI-Leputen-Utils/Resize Power of 2
ComfyUI Node

Resize Power of 2

Your engine just refused a 1023px texture — resize to power of 2, the boring way

By lilquail·Created 9 months ago·Updated 9 months ago· 1
Resize Power of 2
  • image
  • image
modeNearest
methodResize
crop_positionCenter
resampleLanczos

Some game engines, and a whole pile of older graphics APIs, want texture dimensions that are powers of two: 256, 512, 1024, 2048. Generate an image at 1023×1023 in ComfyUI and you've got a texture that won't import, won't mipmap, or gets silently padded into a blurry mess. Resize Power of 2 snaps dimensions to the nearest power of two - either by scaling the image or cropping it - so your output actually lands in an engine.

Modern engines mostly stopped caring (they'll accept NPOT textures and handle them fine), but DDS compression, certain pipelines, and legacy targets still enforce it. If you're producing game textures, this is the "make it conform" step at the end of the graph, right before Save DDS Image or Save Image.

How it works

It computes the target size per axis independently - width and height each snap to a power of 2 - then either resizes the image to those dimensions or crops it down to them, depending on your method:

  • Resize - scales the whole image. You lose some pixels of detail if you're shrinking, but nothing gets cut.
  • Crop - cuts the image to the target size instead. Preserves 1:1 pixels, but you lose content, so the crop_position input (nine-way: Top-Left through Bottom-Right, default Center) decides what survives.

The mode input controls which power of 2 you land on:

  • Nearest - the closest one. 300 becomes 256, 700 becomes 512 (actually 512, since 700 is closer to 512 than 1024). The default, and usually what you want.
  • Up - the next larger. 300 → 512. Use it when you'd rather upscale than lose detail.
  • Down - the previous smaller. 300 → 256. Use it when you need the smaller footprint.

There's also resample (Lanczos / Bilinear / Nearest) for the resize path. Lanczos is the default and the highest quality; Nearest is there if you want crisp pixel-art scaling or speed. One IMAGE in, one IMAGE out, batch-friendly.

Install

Leputen Utils is lilquail's Windows-oriented texture toolkit. Install with ComfyUI Manager (search "ComfyUI-Leputen-Utils") or:

cd ComfyUI/custom_nodes
git clone https://github.com/lilquail/ComfyUI-Leputen-Utils

Restart ComfyUI. This node is a PIL resize - zero model downloads, zero optional dependencies.

Where people get burned

Two things trip people up. First, the per-axis snapping: a 1920×1080 image becomes 2048×1024 - different power on each axis - which changes the aspect ratio. That's correct behavior for the constraint, but it can surprise you if you expected both dimensions to change by the same factor. Second, if the image is already a power of 2 on an axis, that axis is left untouched; the node only modifies what needs changing.

If you're coming from a photography background and the word "crop" makes you nervous, the safe play is Nearest + Resize + Lanczos: minimal change, best quality. Reserve Crop for when you genuinely can't afford to resize (normal maps and height maps where you want to keep exact pixel data). And honestly - if you're on a fully modern engine, ask whether you need this at all before you eat the resize.

CategoryLeputen-Utils/Utility

Inputs (5)

NameTypeDefaultDescription
imageIMAGEThe image tensor to resize or crop.
modeCOMBONearestNearest: closest power of 2. Up: next larger. Down: previous smaller.
methodoptCOMBOResizeResize: scale image to new dimensions. Crop: cut image to new dimensions.
crop_positionoptCOMBOCenterCrop alignment when using Crop method.
resampleoptCOMBOLanczosResampling filter for resize. Lanczos: highest quality. Bilinear: balanced. Nearest: pixelated.

Outputs (1)

NameTypeDescription
imageIMAGE