Comfy-Org/ComfyUI · error · ValueError

Custom size out of range: {w}x{h}. Both width and height mus

Error message

Custom size out of range: {w}x{h}. Both width and height must be between 512 and 2048 pixels.

What it means

ByteDance text-to-image: when size_preset does not match any RECOMMENDED_PRESETS label, the node falls back to the custom width/height widgets and requires both to be within 512-2048 pixels (the API's accepted range for this endpoint).

Source

Thrown at comfy_api_nodes/nodes_bytedance.py:535

        prompt: str,
        size_preset: str,
        width: int,
        height: int,
        seed: int,
        guidance_scale: float,
        watermark: bool,
    ) -> IO.NodeOutput:
        validate_string(prompt, strip_whitespace=True, min_length=1)
        w = h = None
        for label, tw, th in RECOMMENDED_PRESETS:
            if label == size_preset:
                w, h = tw, th
                break

        if w is None or h is None:
            w, h = width, height
            if not (512 <= w <= 2048) or not (512 <= h <= 2048):
                raise ValueError(
                    f"Custom size out of range: {w}x{h}. " "Both width and height must be between 512 and 2048 pixels."
                )

        payload = Text2ImageTaskCreationRequest(
            model=model,
            prompt=prompt,
            size=f"{w}x{h}",
            seed=seed,
            guidance_scale=guidance_scale,
            watermark=watermark,
        )
        response = await sync_op(
            cls,
            ApiEndpoint(path=BYTEPLUS_IMAGE_ENDPOINT, method="POST"),
            data=payload,
            response_model=ImageTaskCreationResponse,
        )
        return IO.NodeOutput(await download_url_to_image_tensor(get_image_url_from_response(response)))

View on GitHub (pinned to 1c6d8d45b3)

Solutions

  1. Set width and height widgets to values in [512, 2048].
  2. Or pick a recommended preset label that exists in the current widget list.
  3. For larger outputs, use the Seedream node (which allows up to ~16MP) instead of this text-to-image endpoint.

Example fix

// before
size_preset: 'custom', width: 4096, height: 4096
// after
size_preset: 'custom', width: 2048, height: 2048
Defensive patterns

Strategy: validation

Validate before calling

if size_preset not in PRESET_LABELS:
    assert 512 <= width <= 2048 and 512 <= height <= 2048, 'custom size must be 512-2048'

Prevention

When it happens

Trigger: size_preset widget set to a custom entry (or stale label not in RECOMMENDED_PRESETS) and width or height outside [512, 2048], e.g. 256 or 4096.

Common situations: Hand-edited workflow JSON with a size label that no longer exists after a node update (falls through to custom values); user types 4096 hoping for 4K on an endpoint capped at 2048.

Related errors


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