Image Prep:
The ImagePrep node is designed to preprocess images for use in Large Language Model (LLM) vision inputs by converting them into base64 data-URIs. This node is particularly useful for preparing images to be embedded directly into text-based data streams, allowing for seamless integration of visual content into applications that utilize LLMs. By supporting both torch.Tensor and PIL.Image formats, ImagePrep offers flexibility in handling different image data types. The node can process up to eight images at a time, encoding them into a format that is easily transferable and compatible with web-based applications. This capability is essential for AI artists and developers who need to incorporate visual data into their LLM workflows efficiently.
Image Prep Input Parameters:
image
This parameter represents the primary image to be processed. It can be either a torch.Tensor or a PIL.Image. The image is converted into a base64 data-URI, which is a text representation of the image that can be easily embedded into HTML or JSON. The quality of the encoding can be adjusted based on the format and quality settings.
format
The format parameter specifies the desired output format for the image encoding. Common options include "PNG", "JPEG", and "WebP". The choice of format affects the compression and quality of the resulting image data-URI. For instance, "JPEG" and "WebP" formats allow for quality adjustments, which can impact the file size and visual fidelity of the image.
quality
This parameter determines the quality level of the image encoding when using formats that support quality adjustments, such as "JPEG" and "WebP". The options are "High", "Medium", and "Low", corresponding to quality values of 95, 75, and 50, respectively. Higher quality settings result in larger file sizes but better image fidelity, while lower settings reduce file size at the cost of image quality.
Image Prep Output Parameters:
urls
The output is a JSON-encoded list of base64 data-URIs representing the processed images. Each URI is a text string that encodes the image data, allowing it to be easily embedded in web pages or transmitted over networks. This output is crucial for integrating visual content into applications that require image data in a text-compatible format.
Image Prep Usage Tips:
- To optimize image quality and file size, choose the appropriate format and quality settings based on your specific needs. For web applications, "WebP" with medium quality can offer a good balance between size and quality.
- When processing multiple images, ensure that all images are either
torch.TensororPIL.Imageto avoid compatibility issues.
Image Prep Common Errors and Solutions:
Unsupported image type. Expected torch.Tensor or PIL.Image.
- Explanation: This error occurs when the input image is neither a
torch.Tensornor aPIL.Image. - Solution: Ensure that the input image is converted to one of the supported formats before passing it to the node.
At least one image input must be provided.
- Explanation: This error is raised when no images are provided for processing.
- Solution: Provide at least one valid image input to the node to proceed with the encoding process.
