invoke-ai/InvokeAI · error · ValueError

Source longer side ({long_side}px) is smaller than the Wan p

Error message

Source longer side ({long_side}px) is smaller than the Wan pixel grid ({multiple}px). Use an input image at least {multiple}px on its longer side.

What it means

Wan models require output dimensions snapped to a pixel grid (16px for 8x-VAE models, 32px for the 16x-VAE TI2V-5B). If the source's longer side is smaller than that grid multiple, the clamp would silently collapse the result to multiple x multiple, destroying the requested aspect ratio. The node raises instead so the workflow author fixes the input image.

Source

Thrown at invokeai/app/invocations/wan_ideal_dimensions.py:70

    multiple: int,
) -> tuple[int, int]:
    """Scale a source W×H so its shorter side equals ``target_short_side``, then
    snap each dimension to ``multiple`` using the requested rounding mode.

    ``multiple`` is the Wan pixel-grid constraint (16 for the 8x-VAE I2V/T2V
    models, 32 for the 16x-VAE TI2V-5B). Shared by both ideal-dimensions nodes.
    """
    short = min(width, height)
    if short <= 0:
        raise ValueError("Source dimensions must be positive.")

    # Reject sources so narrow that the scaled long side is still under one Wan
    # pixel grid. The downstream clamp to ``max(w, multiple)`` would otherwise
    # silently return multiple×multiple, which has no relation to the requested
    # aspect ratio — better to fail fast and have the workflow author fix inputs.
    long_side = max(width, height)
    if long_side < multiple:
        raise ValueError(
            f"Source longer side ({long_side}px) is smaller than the Wan pixel grid ({multiple}px). "
            f"Use an input image at least {multiple}px on its longer side."
        )

    scale = target_short_side / short
    raw_w = width * scale
    raw_h = height * scale

    if rounding == "floor":
        w = int(raw_w // multiple) * multiple
        h = int(raw_h // multiple) * multiple
    elif rounding == "ceiling":
        w = int(math.ceil(raw_w / multiple)) * multiple
        h = int(math.ceil(raw_h / multiple)) * multiple
    else:  # nearest
        w = round(raw_w / multiple) * multiple
        h = round(raw_h / multiple) * multiple

View on GitHub (pinned to 0b6a024f2f)

Solutions

  1. Upscale or replace the input image so its longer side is at least the grid multiple (>=16px, or >=32px for TI2V-5B)
  2. Use the ideal-dimensions node matching your model's multiple (16 vs 32)
  3. Check upstream resize/crop nodes that may have shrunk the image

Example fix

// before
inputImage: 12x20px, multiple=16  -> error
// after
inputImage: 480x800px (or upscaled) then Wan Ideal Dimensions
Defensive patterns

Strategy: validation

Validate before calling

multiple = 32 if model_is_16x_vae else 16
if max(width, height) < multiple:
    raise ValueError(f"image longer side must be >= {multiple}px")

Try / catch

try:
    dims = ideal_dims.invoke(context)
except ValueError as e:
    if 'smaller than the Wan pixel grid' in str(e):
        upscale_image_to_at_least(multiple)
    else:
        raise

Prevention

When it happens

Trigger: Feeding a tiny image (longer side < 16 or < 32 px, e.g. a 12x12 thumbnail) into Wan Ideal Dimensions; using multiple=32 (TI2V-5B) with a small image whose long side is under 32px.

Common situations: Downscaled or placeholder images in automated pipelines; switching to the 16x-VAE model (multiple=32) without enlarging previously-fine small inputs.

Related errors


AI-assisted analysis of invoke-ai/InvokeAI@0b6a024f2f (2026-08-29). Data as JSON: /api/errors/0c879e9663797ef7. Report an issue: GitHub.