Comfy-Org/ComfyUI · error · ValueError

Image height must be at least {min_height}px, got {height}px

Error message

Image height must be at least {min_height}px, got {height}px

What it means

ValueError from validate_image_dimensions when image height is below the required minimum. Height is shape[1] for [B,H,W,C] and shape[0] for [H,W,C]. Enforced before the API call so undersized images fail fast with a clear message.

Source

Thrown at comfy_api_nodes/util/validation_utils.py:31

    else:
        raise ValueError("Invalid image tensor shape.")


def validate_image_dimensions(
    image: torch.Tensor,
    min_width: int | None = None,
    max_width: int | None = None,
    min_height: int | None = None,
    max_height: int | None = None,
):
    height, width = get_image_dimensions(image)

    if min_width is not None and width < min_width:
        raise ValueError(f"Image width must be at least {min_width}px, got {width}px")
    if max_width is not None and width > max_width:
        raise ValueError(f"Image width must be at most {max_width}px, got {width}px")
    if min_height is not None and height < min_height:
        raise ValueError(f"Image height must be at least {min_height}px, got {height}px")
    if max_height is not None and height > max_height:
        raise ValueError(f"Image height must be at most {max_height}px, got {height}px")


def validate_image_aspect_ratio(
    image: torch.Tensor,
    min_ratio: tuple[float, float] | None = None,  # e.g. (1, 4)
    max_ratio: tuple[float, float] | None = None,  # e.g. (4, 1)
    *,
    strict: bool = True,  # True -> (min, max); False -> [min, max]
) -> float:
    """Validates that image aspect ratio is within min and max. If a bound is None, that side is not checked."""
    w, h = get_image_dimensions(image)
    if w <= 0 or h <= 0:
        raise ValueError(f"Invalid image dimensions: {w}x{h}")
    ar = w / h
    _assert_ratio_bounds(ar, min_ratio=min_ratio, max_ratio=max_ratio, strict=strict)
    return ar

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Upscale or re-generate to reach height >= min_height.
  2. Fix upstream resize nodes producing too-small outputs.
  3. Pick a provider/node with lower minimum height requirements.
Defensive patterns

Strategy: validation

Validate before calling

def check_min_height(image: torch.Tensor, min_height: int) -> bool:
    h = image.shape[1] if image.dim() == 4 else image.shape[0]
    return h >= min_height

Prevention

When it happens

Trigger: validate_image_dimensions(image, min_height=N) with height < N — e.g., a 512x512 image into a node requiring min_height=768.

Common situations: Small source images or aggressive downscaling in the workflow; square images failing tall-format requirements of a provider.

Related errors


AI-assisted analysis of Comfy-Org/ComfyUI@1c6d8d45b3 (2026-08-14). Data as JSON: /api/errors/f14bbce55f89e0f1. Report an issue: GitHub.