1 Star 0 Fork 0

suifengpiao/ComfyScript

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Images

Loading

From path

def LoadImageFromPath(
    image: str = r'ComfyUI_00001_-assets\ComfyUI_00001_.png [output]'
) -> tuple[Image, Mask]

One use of this node is to work with Photoshop's Quick Export to quickly perform img2img/inpaint on the edited image. Update: For working with Photoshop, comfyui-photoshop is more convenient and supports waiting for changes. See tutorial at r/comfyui.

From Base64

def ETNLoadImageBase64(
    image: str
) -> tuple[Image, Mask]

def ETNLoadMaskBase64(
    mask: str
) -> Mask

From empty

def EmptyImage(
    width: int = 512,
    height: int = 512,
    batch_size: int = 1,
    color: int = 0
) -> Image

From Photoshop (not built-in)

def PhotoshopToComfyUI(
    password: str = '12341234',
    wait_for_photoshop_changes: bool = False
) -> tuple[Image, Int, Int]

See tutorial at r/comfyui.

From PIL.Image.Image (real mode)

def PILToImage(
    images: PilImage
) -> Image

def PILToMask(
    images: PilImage
) -> Image

From input directory

def LoadImage(
    image: LoadImage.image = 'ComfyUI_00001_.png'
) -> tuple[Image, Mask]

def LoadImageMask(
    image: LoadImageMask.image = 'ComfyUI_00001_.png',
    channel: LoadImageMask.channel = 'alpha'
) -> Mask

Saving

To output directory

def SaveImage(
    images: Image,
    filename_prefix: str = 'ComfyUI'
)

Retrieving the saved images:

from PIL import Image

image = EmptyImage(512, 512, 1)
image = SaveImage(image, 'ComfyUI')

image_batch = image.wait()

# Get the first image
image: Image.Image = image_batch[0]

# Get all images in the batch
images: list[Image.Image] = image_batch.wait()

Or with await:

from PIL import Image

image = EmptyImage(512, 512, 1)
image = SaveImage(image, 'ComfyUI')

image_batch = await image

# Get the first image
image: Image.Image = await image_batch.get(0)

# Get all images in the batch
images: list[Image.Image] = await image_batch

To temp directory

def PreviewImage(
    images: Image
)

Retrieving the preview images:

from PIL import Image

image = EmptyImage(512, 512, 1)
image = PreviewImage(image)

image_batch = image.wait()

# Get the first image
image: Image.Image = image_batch[0]

# Get all images in the batch
images: list[Image.Image] = image_batch.wait()

Or with await:

from PIL import Image

image = EmptyImage(512, 512, 1)
image = PreviewImage(image)

image_batch = await image

# Get the first image
image: Image.Image = await image_batch.get(0)

# Get all images in the batch
images: list[Image.Image] = await image_batch

To client

def ETNSendImageWebSocket(
    images: Image
)

Sends an output image over the client WebSocket connection as PNG binary data.

To PIL.Image.Image (real mode)

def ImageToPIL(
    images: Image
) -> PilImage

To animation

def SaveAnimatedWEBP(
    images: Image,
    filename_prefix: str = 'ComfyUI',
    fps: float = 6.0,
    lossless: bool = True,
    quality: int = 80,
    method: SaveAnimatedWEBP.method = 'default'
)

def SaveAnimatedPNG(
    images: Image,
    filename_prefix: str = 'ComfyUI',
    fps: float = 6.0,
    compress_level: int = 4
)

Masking

Creating:

def SolidMask(
    value: float = 1.0,
    width: int = 512,
    height: int = 512
) -> Mask

def ImageToMask(
    image: Image,
    channel: ImageToMask.channel = 'red'
) -> Mask

def ImageColorToMask(
    image: Image,
    color: int = 0
) -> Mask

def MaskToImage(
    mask: Mask
) -> Image

Applying:

def ETNApplyMaskToImage(
    image: Image,
    mask: Mask
) -> Image

Batching

def ImageBatch(
    image1: Image,
    image2: Image
) -> Image

def RebatchImages(
    images: Image,
    batch_size: int = 1
) -> Image

def RepeatImageBatch(
    image: Image,
    amount: int = 1
) -> Image
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/piaoddang/ComfyScript.git
git@gitee.com:piaoddang/ComfyScript.git
piaoddang
ComfyScript
ComfyScript
main

搜索帮助