Files
CavinHuang-comfyui-nodes-docs/docs/Inference_Core_ImageGenResolutionFromImage.md
2024-07-04 08:39:03 +08:00

1.4 KiB

Documentation

此节点旨在直接从输入图像计算生成分辨率。它提取输入图像的宽度和高度,并将这些尺寸作为预期的图像生成分辨率返回,从而便于根据输入图像的尺寸调整输出图像的大小。

Input types

Required

  • image
    • 需要计算生成分辨率的输入图像。使用该图像的尺寸来确定输出分辨率,直接影响生成图像的大小。
    • Comfy dtype: IMAGE
    • Python dtype: numpy.ndarray

Output types

  • IMAGE_GEN_WIDTH (INT)
    • 从输入图像提取的宽度值,用于设置生成图像的宽度。
    • Comfy dtype: INT
    • Python dtype: int
  • IMAGE_GEN_HEIGHT (INT)
    • 从输入图像提取的高度值,用于设置生成图像的高度。
    • Comfy dtype: INT
    • Python dtype: int

Usage tips

  • Infra type: CPU
  • Common nodes: unknown

Source code

class ImageGenResolutionFromImage:
    @classmethod
    def INPUT_TYPES(s):
        return {
            "required": { "image": ("IMAGE", ) }
        }
    
    RETURN_TYPES = ("INT", "INT")
    RETURN_NAMES = ("IMAGE_GEN_WIDTH (INT)", "IMAGE_GEN_HEIGHT (INT)")
    FUNCTION = "execute"

    CATEGORY = "ControlNet Preprocessors"

    def execute(self, image):
        _, H, W, _ = image.shape
        return (W, H)