Visit ComfyUI Online for ready-to-use ComfyUI environment
Resize images based on specified megapixels, maintaining aspect ratio and quality with various upscaling methods.
The IMG_scaler
node is designed to resize images based on a specified total number of megapixels. This node is particularly useful when you need to upscale or downscale an image to fit within a certain resolution while maintaining the aspect ratio. By specifying the desired number of megapixels, the node calculates the appropriate dimensions and applies the selected upscaling method to achieve the target resolution. This ensures that the image quality is preserved as much as possible during the scaling process. The node supports various upscaling methods, allowing you to choose the one that best suits your needs, whether you prioritize speed, quality, or a balance of both.
This parameter represents the input image that you want to scale. The image should be provided in a format that the node can process, typically as a tensor or array.
This parameter allows you to select the method used for upscaling the image. The available options are "nearest-exact"
, "bilinear"
, "area"
, "bicubic"
, and "lanczos"
. Each method has its own characteristics: "nearest-exact"
is fast but may produce blocky results, "bilinear"
and "bicubic"
offer smoother results, "area"
is good for downscaling, and "lanczos"
provides high-quality results but is computationally intensive.
This parameter specifies the total number of megapixels for the output image. It determines the target resolution by calculating the appropriate width and height to achieve the specified megapixels while maintaining the aspect ratio. The value can range from 0.01 to 16.0 megapixels, with a default value of 1.0 megapixels. Adjusting this parameter allows you to control the final size and quality of the scaled image.
The output parameter is the scaled image. This image is resized according to the specified number of megapixels and the chosen upscaling method. The output maintains the aspect ratio of the original image, ensuring that the content is not distorted during the scaling process.
"lanczos"
method, especially for images with fine details."nearest-exact"
method can be a good choice due to its speed."area"
method is effective in preserving the overall appearance and reducing aliasing artifacts.ValueError: Invalid upscale method
upscale_method
parameter is set to one of the following valid options: "nearest-exact"
, "bilinear"
, "area"
, "bicubic"
, or "lanczos"
.ValueError: Megapixels out of range
megapixels
parameter is set to a value outside the allowed range (0.01 to 16.0).megapixels
parameter to a value within the valid range.TypeError: Invalid image format
© Copyright 2024 RunComfy. All Rights Reserved.