{"record":{"id":"b88d129593031027","repo":"Comfy-Org/ComfyUI","slug":"image-height-must-be-at-most-max-height-px-got","errorCode":null,"errorMessage":"Image height must be at most {max_height}px, got {height}px","messagePattern":"Image height must be at most (.+?)px, got (.+?)px","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/util/validation_utils.py","lineNumber":33,"sourceCode":"\n\ndef validate_image_dimensions(\n    image: torch.Tensor,\n    min_width: int | None = None,\n    max_width: int | None = None,\n    min_height: int | None = None,\n    max_height: int | None = None,\n):\n    height, width = get_image_dimensions(image)\n\n    if min_width is not None and width < min_width:\n        raise ValueError(f\"Image width must be at least {min_width}px, got {width}px\")\n    if max_width is not None and width > max_width:\n        raise ValueError(f\"Image width must be at most {max_width}px, got {width}px\")\n    if min_height is not None and height < min_height:\n        raise ValueError(f\"Image height must be at least {min_height}px, got {height}px\")\n    if max_height is not None and height > max_height:\n        raise ValueError(f\"Image height must be at most {max_height}px, got {height}px\")\n\n\ndef validate_image_aspect_ratio(\n    image: torch.Tensor,\n    min_ratio: tuple[float, float] | None = None,  # e.g. (1, 4)\n    max_ratio: tuple[float, float] | None = None,  # e.g. (4, 1)\n    *,\n    strict: bool = True,  # True -> (min, max); False -> [min, max]\n) -> float:\n    \"\"\"Validates that image aspect ratio is within min and max. If a bound is None, that side is not checked.\"\"\"\n    w, h = get_image_dimensions(image)\n    if w <= 0 or h <= 0:\n        raise ValueError(f\"Invalid image dimensions: {w}x{h}\")\n    ar = w / h\n    _assert_ratio_bounds(ar, min_ratio=min_ratio, max_ratio=max_ratio, strict=strict)\n    return ar\n\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/util/validation_utils.py#L15-L51","documentation":"ValueError from validate_image_dimensions when image height exceeds the allowed maximum. Mirrors the max_width check: height comes from get_image_dimensions and is compared to max_height when provided. Fails before upload so oversized images never reach the API.","triggerScenarios":"validate_image_dimensions(image, max_height=N) with height > N — e.g., a 4096px-tall image into a node capping max_height=2048.","commonSituations":"Upscaled or stitched tall images; print/poster-resolution outputs; forgetting downscale before an API node.","solutions":["Downscale so height <= max_height.","Crop or split tall images and process in chunks.","Adjust the workflow's upscale factor to stay under the cap."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"def check_max_height(image: torch.Tensor, max_height: int) -> bool:\n    h = image.shape[1] if image.dim() == 4 else image.shape[0]\n    return h <= max_height","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Downscale tall/portrait images before API nodes","Tile oversized images instead of forcing them through"],"tags":["validation","image","dimensions"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}