ComfyUI > Nodes > comfy_Pond_Nodes > 🐳宽高比计算

ComfyUI Node: 🐳宽高比计算

Class Name

AspectRatioCalculator

Category
🐳Pond/Tools
Author
Pondowner857 (Account age: 730days)
Extension
comfy_Pond_Nodes
Latest Updated
2026-01-28
Github Stars
0.04K

How to Install comfy_Pond_Nodes

Install this extension via the ComfyUI Manager by searching for comfy_Pond_Nodes
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter comfy_Pond_Nodes 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

🐳宽高比计算 Description

Calculates and adjusts image/video aspect ratios, preserving dimensions for AI art projects.

🐳宽高比计算:

The AspectRatioCalculator node is designed to help you efficiently calculate and adjust the aspect ratio of images or videos. This tool is particularly useful for AI artists who need to maintain specific dimensions or ratios for their creative projects. By providing a flexible and intuitive interface, the AspectRatioCalculator allows you to input desired dimensions and constraints, and it automatically computes the optimal width and height while preserving the aspect ratio. This ensures that your visual content maintains its intended proportions, whether you're working with standard ratios like 16:9 or custom dimensions. The node's ability to handle various target modes and constraint settings makes it a versatile tool for achieving precise visual outputs, enhancing the quality and consistency of your artistic work.

🐳宽高比计算 Input Parameters:

width

The width parameter specifies the initial width of the image or video. It is an integer value that can range from 1 to 10,000, with a default value of 1920. This parameter is crucial as it serves as the starting point for calculating the aspect ratio and adjusting the dimensions based on the target mode and constraints you set.

height

The height parameter defines the initial height of the image or video. Like the width, it is an integer value ranging from 1 to 10,000, with a default value of 1080. This parameter works in conjunction with the width to determine the original aspect ratio, which is then used to calculate the new dimensions according to your specified settings.

target_value

The target_value parameter is an integer that represents the desired dimension for the target mode you select. It ranges from 1 to 10,000, with a default value of 1024. Depending on the target mode, this value will either set the new width, height, or influence the maximum or minimum dimension or area, guiding the recalculation of the aspect ratio.

target_mode

The target_mode parameter allows you to choose how the target value should be applied. Options include "width," "height," "max_dimension," "min_dimension," and "area," with "width" as the default. This setting determines which dimension or property will be adjusted to meet the target value, affecting how the aspect ratio is recalculated.

constraint_mode

The constraint_mode parameter specifies how the aspect ratio should be maintained or adjusted. Options include "keep_ratio," "max_total," and "min_total," with "keep_ratio" as the default. This setting influences whether the original aspect ratio is preserved or if other constraints, such as total dimensions, are prioritized during the calculation.

round_to

The round_to parameter is an integer that determines the granularity of the rounding applied to the calculated dimensions. It ranges from 1 to 64, with a default value of 8. This parameter ensures that the final dimensions are rounded to a multiple of the specified value, which can be important for compatibility with certain display or processing requirements.

preset_ratio

The preset_ratio parameter allows you to select from predefined aspect ratios such as "1:1," "4:3," "16:9," etc., with "custom" as the default. This setting provides a quick way to apply common aspect ratios without manually calculating them, streamlining the process of adjusting your visual content to standard dimensions.

max_width

The max_width parameter sets an upper limit on the width of the output dimensions. It is an integer ranging from 1 to 10,000, with a default value of 4096. This constraint ensures that the calculated width does not exceed a specified maximum, which can be important for maintaining compatibility with certain display or processing requirements.

max_height

The max_height parameter sets an upper limit on the height of the output dimensions. Like max_width, it is an integer ranging from 1 to 10,000, with a default value of 4096. This constraint ensures that the calculated height does not exceed a specified maximum, helping to maintain compatibility with certain display or processing requirements.

🐳宽高比计算 Output Parameters:

width

The width output parameter provides the calculated width of the image or video after applying the specified aspect ratio and constraints. This value is crucial for ensuring that your visual content maintains the desired proportions and fits within any specified limits.

height

The height output parameter provides the calculated height of the image or video after applying the specified aspect ratio and constraints. Like the width, this value is essential for maintaining the intended proportions and ensuring compatibility with display or processing requirements.

ratio_text

The ratio_text output parameter is a string representation of the calculated aspect ratio. This text provides a clear and concise way to understand the proportions of the output dimensions, making it easier to verify that the desired aspect ratio has been achieved.

info

The info output parameter is a string that contains additional information about the calculation process, such as the original and adjusted dimensions or any constraints applied. This information can be helpful for understanding how the final dimensions were determined and for troubleshooting any issues that may arise.

🐳宽高比计算 Usage Tips:

  • To maintain a specific aspect ratio while adjusting dimensions, use the "keep_ratio" constraint mode and set the target mode to either "width" or "height" based on your priority.
  • Utilize the preset_ratio parameter to quickly apply common aspect ratios, saving time and ensuring consistency with standard dimensions.

🐳宽高比计算 Common Errors and Solutions:

"Aspect ratio must be 'X:Y' (e.g., 16:9), got 'invalid_input'."

  • Explanation: This error occurs when the aspect ratio string is not formatted correctly.
  • Solution: Ensure that the aspect ratio is provided in the correct "X:Y" format, using positive integers for both parts.

"Video width must be at most max_width px, got width px."

  • Explanation: This error indicates that the calculated width exceeds the specified maximum width.
  • Solution: Adjust the max_width parameter to a higher value or modify the target mode and constraints to reduce the calculated width.

"Video height must be at most max_height px, got height px."

  • Explanation: This error indicates that the calculated height exceeds the specified maximum height.
  • Solution: Adjust the max_height parameter to a higher value or modify the target mode and constraints to reduce the calculated height.

🐳宽高比计算 Related Nodes

Go back to the extension to check out more related nodes.
comfy_Pond_Nodes
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 Models, enabling artists to harness the latest AI tools to create incredible art.

🐳宽高比计算