ComfyUI Node: IMG_scaler

Class Name

IMG_scaler

Category
Eden 🌱/Image
Author
aiXander (Account age: 302days)
Extension
Various custom nodes by Eden.art
Latest Updated
2024-07-23
Github Stars
0.04K

How to Install Various custom nodes by Eden.art

Install this extension via the ComfyUI Manager by searching for Various custom nodes by Eden.art
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Various custom nodes by Eden.art in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • High-speed GPU machines
  • 200+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 50+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

IMG_scaler Description

Resize images based on specified megapixels, maintaining aspect ratio and quality with various upscaling methods.

IMG_scaler:

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.

IMG_scaler Input Parameters:

image

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.

upscale_method

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.

megapixels

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.

IMG_scaler Output Parameters:

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.

IMG_scaler Usage Tips:

  • To achieve the best quality when upscaling, consider using the "lanczos" method, especially for images with fine details.
  • If you need to quickly upscale an image and quality is not the primary concern, the "nearest-exact" method can be a good choice due to its speed.
  • When downscaling images, the "area" method is effective in preserving the overall appearance and reducing aliasing artifacts.
  • Experiment with different megapixel values to find the optimal balance between image size and quality for your specific use case.

IMG_scaler Common Errors and Solutions:

ValueError: Invalid upscale method

  • Explanation: This error occurs when an unsupported upscaling method is specified.
  • Solution: Ensure that the upscale_method parameter is set to one of the following valid options: "nearest-exact", "bilinear", "area", "bicubic", or "lanczos".

ValueError: Megapixels out of range

  • Explanation: This error occurs when the megapixels parameter is set to a value outside the allowed range (0.01 to 16.0).
  • Solution: Adjust the megapixels parameter to a value within the valid range.

TypeError: Invalid image format

  • Explanation: This error occurs when the input image is not in a format that the node can process.
  • Solution: Ensure that the input image is provided as a tensor or array in a compatible format.

IMG_scaler Related Nodes

Go back to the extension to check out more related nodes.
Various custom nodes by Eden.art
RunComfy

© Copyright 2024 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals.