Run ComfyUI Easily with InstaSD

Skip the complex setup. InstaSD helps creative professionals build workflows and deploy them to the world:

  • One-click deployment
  • Any model, any node
  • Powerful GPUs for rapid iteration
Get Started

Available Nodes

LoadAndResizeImage

LoadAndResizeImage Node Documentation

Overview

The LoadAndResizeImage node is a utility function within the ComfyUI framework, particularly useful for loading images from a designated input directory and performing optional resizing operations. This node offers various configuration options for image handling, such as maintaining the aspect ratio and extracting specific color channels for mask output. It is particularly beneficial in workflows that require fetching and preparing images efficiently for further processing within ComfyUI.

Functionality

The primary function of the LoadAndResizeImage node is to load an image from a specified directory, optionally resize it according to user preferences, and provide an option to repeat the image multiple times to create an image batch. Additionally, users can specify how to handle the image's alpha channel or other color channels for mask output, and optionally apply a background color when filling the alpha channel.

Inputs

  1. image: This input expects a filename. The file should exist within the input directory specified in the ComfyUI configuration. The node will load this image for processing.

  2. resize: A boolean input indicating whether the loaded image should be resized or not. If True, the node will adjust the image dimensions as specified.

  3. width: An integer specifying the desired width of the image if resizing is enabled.

  4. height: An integer specifying the desired height of the image if resizing is enabled.

  5. repeat: An integer value representing how many times the loaded image should be repeated to form a batch of images.

  6. keep_proportion: A boolean input determining whether to maintain the original aspect ratio of the image during resizing. When True, the image will resize according to the higher dimension.

  7. divisible_by: An integer that ensures the resized image dimensions are divisible by the specified value for better compatibility with some neural network operations.

  8. mask_channel: This dropdown input allows selection of which color channel (alpha, red, green, or blue) will be used for creating the mask output.

  9. background_color: An optional string input representing the background color as RGB values or a hexadecimal color code. It is used to fill the alpha channel when converting it to RGB.

Outputs

  1. image: The processed image as a tensor, possibly resized and repeated according to the input parameters.

  2. mask: A mask generated from the specified color channel.

  3. width: The width of the output image.

  4. height: The height of the output image.

  5. image_path: The path of the loaded image file.

Usage in ComfyUI Workflows

The LoadAndResizeImage node is invaluable in a variety of ComfyUI workflows, primarily where image input and preprocessing are required. Common use cases include:

  • Preprocessing: Before feeding an image into a neural network or any further processing nodes, it might be necessary to load, resize, and prepare the image. This node can handle those tasks without manual intervention.

  • Batch Creation: By using the repeat functionality, users can easily create batches of identical images for experiments requiring consistent input.

  • Aspect Ratio Maintenance: This node efficiently handles aspect ratio considerations, ensuring that the resulting images maintain expected visuals despite dimension changes.

  • Mask Handling: By selecting a specific color channel for mask output, users can convert meaningful parts of the image into masks for tasks like segmentation or selective processing.

Special Features and Considerations

  • Background Color Handling: The node has a unique feature allowing users to apply a background color when the alpha channel is present, converting the image to RGB format while optionally filling transparent areas.

  • Multiple Formats: This node proficiently handles various image formats, automatically managing conversions and potential exif data discrepancies for consistent processing.

  • Batch Flexibility: Users can specify how many times an image should be repeated, which is particularly helpful in batch processing scenarios requiring multiple copies of the same input.

  • Efficient Mask Generation: The node gives flexibility in selecting a channel for mask generation, which can be crucial for workflows needing mask processing or background extraction.

Overall, the LoadAndResizeImage node enhances ComfyUI's capability to handle image inputs efficiently and flexibly, catering to a wide range of requirements from basic loading and resizing to complex mask generation and batch processing tasks.