Skip to content

Latest commit

 

History

History
236 lines (193 loc) · 5.37 KB

README.md

File metadata and controls

236 lines (193 loc) · 5.37 KB

Images

Metadata

By default, ComfyUI and ComfyScript will save the workflow into the generated image's metadata (in both virtual and real mode). The workflow can then be loaded from the image into ComfyUI's web UI and ComfyScript's MetadataViewer.

You can disable this behavior by passing --disable-metadata when launching ComfyUI. If you start ComfyUI in ComfyScript, use the following code:

from comfy_script.runtime import *
load(args=ComfyUIArgs('--disable-metadata'))
from comfy_script.runtime.nodes import *

Note that only PNG images are fully supported, WebP may cannot be loaded properly due to bugs/limitations in custom nodes and ComfyUI.

Loading

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.

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.

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
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