Nodes/ComfyUI-TextureAlchemy/Smart Texture Resizer
ComfyUI Node

Smart Texture Resizer

Hitting your megapixel budget without ugly dimensions

By amtarr·Created 9 months ago·Updated 4 months ago· 58
Smart Texture Resizer
  • image
  • image
target_megapixels2.00
multiple_of32
resize_modefit_within
scaling_methodlanczos

Most resizing is guessing. You drag a slider until the number "feels right," then discover your texture is 1843×1234 and your game engine glares at you. Smart Texture Resizer resizes the other way: you tell it a megapixel budget and a dimension-alignment rule, and it returns a texture that respects both. If you've ever shipped a material that's one pixel off a multiple-of-32, this node is the apology.

How it works

You set a target_megapixels (0.25 to 16, default 2) and a multiple_of - 4, 8, 16, 32, 64, 128, or 256. The node computes a scale factor from the ratio of target pixels to current pixels, applies it while preserving aspect ratio, then rounds both dimensions to the nearest multiple. That's the whole trick, and it's the one that matters: GPU-friendly and engine-friendly dimensions, automatically.

resize_mode decides how hard it tries:

  • fit_within (default) - scales under the target, with a 5% cushion, so you never accidentally exceed your VRAM budget. The safe choice.
  • fit_exact - gets as close to the target as the multiple allows.
  • no_upscale - only ever shrinks; if the input is already under target it just rounds the dimensions.

scaling_method offers bicubic, bilinear, lanczos, and nearest. One honest detail from the source: PyTorch's interpolate has no true lanczos, so the "lanczos" option actually routes to bicubic. Don't lose sleep over it - bicubic is the quality you'd pick anyway for photographic textures; use nearest for pixel art.

What to reach for it for

Anywhere a texture has to hit a budget: game-engine LODs, VRAM-tight renders, or AI models that want multiples of 8 or 64. The pack's docs pair it right after Square Maker - square the image, then snap it to a GPU-friendly size.

Installing it

Part of amtarr/ComfyUI-TextureAlchemy. ComfyUI Manager → search "Texture Alchemy", or:

cd ComfyUI/custom_nodes
git clone https://github.com/amtarr/ComfyUI-TextureAlchemy

Restart, then right-click → Add Node → Texture Alchemist → Texture. No dependencies, no models.

The honest gotchas

fit_within plus a multiple can land you notably under your target - 2.0 MP with multiple_of 32 gave 1536×864 in the pack's own examples, which is 1.33 MP, not 2.0. That's the cost of the safety margin; pick fit_exact if you truly need the budget filled. And remember rounding a dimension to a multiple can change the aspect ratio slightly - usually invisible, but if you're upscaling, prefer no_upscale unless you actually want the growth. Console banner on every run is just the pack's style.

CategoryTexture Alchemist/Texture

Inputs (5)

NameTypeDefaultDescription
imageIMAGE
target_megapixelsFLOAT2.000.25–16Target size in megapixels (e.g., 2.0 = 2 million pixels)
multiple_ofCOMBO32Ensure width/height are multiples of this value
resize_modeCOMBOfit_withinfit_within (stay under target), fit_exact (closest match), no_upscale (never increase size)
scaling_methodCOMBOlanczosResampling algorithm for quality

Outputs (1)

NameTypeDescription
imageIMAGE