🐟Batch Image Compressor:
The BatchImageCompressor node is designed to efficiently compress multiple images in a directory, making it an invaluable tool for AI artists who need to manage large collections of images. This node automates the process of reducing image file sizes while maintaining quality, which is essential for optimizing storage and improving load times in various applications. By leveraging the capabilities of the BatchImageCompressor, you can process entire directories of images in one go, applying consistent compression settings across all files. This not only saves time but also ensures uniformity in image quality and size, which is crucial for maintaining a cohesive visual presentation. The node supports various image formats, including PNG, JPEG, and WEBP, and provides flexibility in terms of compression quality and resizing options, allowing you to tailor the output to your specific needs.
🐟Batch Image Compressor Input Parameters:
input_path
The input_path parameter specifies the directory path where the images to be compressed are located. It is a required parameter and must be a valid string representing an existing directory. This parameter is crucial as it determines the source of the images that will undergo compression. There are no default values, and the path must be provided by the user.
format
The format parameter defines the output format for the compressed images. Supported formats include .png, .jpg, .jpeg, and .webp. This parameter allows you to choose the desired format based on your needs, such as balancing between quality and file size. The default format is not specified, so you must select one that suits your requirements.
quality
The quality parameter controls the compression quality for lossy formats like JPEG. It is an integer value typically ranging from 1 to 100, where higher values indicate better quality and larger file sizes. The default value is 85, which provides a good balance between quality and compression.
resize_factor
The resize_factor parameter allows you to scale the images during compression. It is a floating-point value where 1.0 means no resizing, values less than 1.0 reduce the image size, and values greater than 1.0 increase it. This parameter is useful for adjusting image dimensions to meet specific requirements. The default value is 1.0.
compression_level
The compression_level parameter is used for formats like PNG that support lossless compression. It is an integer value typically ranging from 0 to 9, where higher values result in smaller file sizes but longer processing times. The default value is 6, offering a balance between compression efficiency and speed.
save_image
The save_image parameter is a boolean that determines whether the compressed images should be saved to disk. If set to True, the images are saved; if False, they are not. This parameter is useful for testing compression settings without writing files. The default value is True.
output_prefix
The output_prefix parameter specifies a prefix to be added to the filenames of the compressed images. This helps in distinguishing compressed files from the originals. It is a string value, and the default is "compressed_".
output_path
The output_path parameter defines the directory where the compressed images will be saved. If not specified, the images are saved in the same directory as the input images. This parameter allows you to organize your files by directing the output to a specific location. The default is an empty string, indicating no specific path is set.
🐟Batch Image Compressor Output Parameters:
compression_info
The compression_info output parameter provides detailed information about the compression process. It is a string that includes the original and compressed sizes of each image, along with their respective file paths. This information is crucial for evaluating the effectiveness of the compression settings and understanding the impact on file sizes.
🐟Batch Image Compressor Usage Tips:
- Ensure that the
input_pathis correctly set to a directory containing images to avoid errors related to non-existent paths. - Experiment with different
qualityandcompression_levelsettings to find the optimal balance between image quality and file size for your specific use case. - Use the
resize_factorto adjust image dimensions if you need to standardize sizes across your image collection. - Consider setting
save_imagetoFalseduring initial testing to quickly evaluate compression settings without writing files to disk.
🐟Batch Image Compressor Common Errors and Solutions:
Input path does not exist: <input_path>
- Explanation: This error occurs when the specified
input_pathdoes not point to an existing directory. - Solution: Verify that the
input_pathis correct and that the directory exists. Ensure there are no typos in the path.
Unsupported image format
- Explanation: This error is raised when an image in the directory is not in one of the supported formats (.png, .jpg, .jpeg, .webp).
- Solution: Ensure all images in the directory are in a supported format or convert unsupported images to a compatible format before compression.
