ComfyUI > Nodes > ComfyUI Steudio > Ratio to Size

ComfyUI Node: Ratio to Size

Class Name

Ratio to Size

Category
Steudio/Utils
Author
Steudio (Account age: 459days)
Extension
ComfyUI Steudio
Latest Updated
2025-05-10
Github Stars
0.04K

How to Install ComfyUI Steudio

Install this extension via the ComfyUI Manager by searching for ComfyUI Steudio
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter ComfyUI Steudio 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
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Ratio to Size Description

Convert aspect ratio to image dimensions for various applications, maintaining visual integrity across mediums.

Ratio to Size:

The Ratio to Size node is designed to convert a given aspect ratio into specific image dimensions, ensuring that the resulting dimensions are optimized for various applications. This node is particularly useful for AI artists who need to maintain specific aspect ratios while adjusting image sizes for different outputs, such as prints, digital displays, or social media platforms. By calculating the dimensions based on a given aspect ratio and megapixel count, the node ensures that the image maintains its intended proportions while fitting within the desired resolution. This functionality is crucial for preserving the visual integrity of artworks and ensuring that they are displayed correctly across different mediums.

Ratio to Size Input Parameters:

ratio

The ratio parameter specifies the aspect ratio that you want to apply to the image. It is a string that represents the width-to-height relationship, such as "16:9" or "4:3". This parameter is crucial as it determines the proportions of the final image dimensions. The available options are predefined in the node, and you can select from common aspect ratios like "1:1", "16:9", "4:3", among others. There are no minimum or maximum values since it is a categorical selection, and the default value is typically set to a common aspect ratio like "1:1".

Megapixel

The Megapixel parameter defines the total number of pixels in millions that the final image should contain. This parameter is essential for determining the resolution of the output image while maintaining the specified aspect ratio. The value is expressed in megapixels, where 1 megapixel equals 1,000,000 pixels. The minimum value is 0.1, and there is no strict maximum, but practical limits depend on the capabilities of your hardware and software. The default value is often set to a standard resolution like 1 megapixel.

Precision

The Precision parameter controls the allowable deviation from the exact aspect ratio when calculating the image dimensions. It is a floating-point number that represents the maximum acceptable difference between the calculated and desired aspect ratios. This parameter is important for ensuring that the final dimensions closely match the specified aspect ratio, which is crucial for maintaining the visual consistency of the image. The minimum value is 0, indicating no deviation, and there is no strict maximum, but higher values may result in noticeable distortion. The default value is typically set to a small number like 0.01 to balance precision and flexibility.

Ratio to Size Output Parameters:

width

The width output parameter represents the calculated width of the image in pixels, based on the specified aspect ratio and megapixel count. This value is crucial for determining the horizontal dimension of the final image, ensuring that it fits within the desired resolution while maintaining the specified proportions. The width is adjusted to be a multiple of 64 to optimize compatibility with various image processing tools and platforms.

height

The height output parameter represents the calculated height of the image in pixels, based on the specified aspect ratio and megapixel count. This value is essential for determining the vertical dimension of the final image, ensuring that it fits within the desired resolution while maintaining the specified proportions. Like the width, the height is adjusted to be a multiple of 64 to optimize compatibility with various image processing tools and platforms.

ui

The ui output parameter provides a formatted string that summarizes the calculated image dimensions, aspect ratio, megapixel count, and precision. This output is useful for quickly verifying the results and ensuring that the calculated dimensions meet your requirements. The ui string is designed to be easily readable and provides a concise overview of the key parameters and results.

Ratio to Size Usage Tips:

  • Ensure that the ratio parameter is set to the desired aspect ratio before calculating the dimensions to avoid unexpected results.
  • Use the Megapixel parameter to control the resolution of the output image, balancing quality and file size based on your needs.
  • Adjust the Precision parameter to allow for slight deviations in aspect ratio if necessary, but keep it small to maintain visual consistency.

Ratio to Size Common Errors and Solutions:

Aspect ratio cannot reduce to any less than <minimum_ratio_str>

  • Explanation: This error occurs when the calculated aspect ratio is smaller than the minimum allowed ratio.
  • Solution: Adjust the ratio parameter to a value that is within the acceptable range or increase the Precision parameter to allow for more flexibility.

Aspect ratio cannot reduce to any greater than <maximum_ratio_str>

  • Explanation: This error occurs when the calculated aspect ratio is larger than the maximum allowed ratio.
  • Solution: Adjust the ratio parameter to a value that is within the acceptable range or increase the Precision parameter to allow for more flexibility.

Ratio to Size Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI Steudio
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Playground, enabling artists to harness the latest AI tools to create incredible art.