ComfyUI Node: cal size

Class Name

canvas-util-cal-size

Category
Ymc Suite/canvas-util
Author
YMC (Account age: 2735days)
Extension
ymc-node-suite-comfyui
Latest Updated
2024-05-22
Github Stars
0.02K

How to Install ymc-node-suite-comfyui

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

cal size Description

Dynamically calculate canvas dimensions with aspect ratio control for precise resizing in ComfyUI Node.

cal size:

The canvas-util-cal-size node is designed to help you dynamically calculate the dimensions of a canvas based on various input parameters. This node is particularly useful when you need to maintain specific aspect ratios or adjust dimensions while keeping one dimension locked. It provides flexibility in resizing canvases by allowing you to specify width, height, aspect ratio, and whether to reverse the dimensions. This node is essential for AI artists who need precise control over canvas sizes for their creative projects, ensuring that the final output meets their exact specifications.

cal size Input Parameters:

w

This parameter specifies the width of the canvas. It accepts integer values with a default of 512, a minimum of 0, and a maximum of 10,000,000. Adjusting this value will directly impact the width of the canvas unless the lockoff parameter is set to lock the width.

h

This parameter specifies the height of the canvas. It accepts integer values with a default of 512, a minimum of 0, and a maximum of 10,000,000. Adjusting this value will directly impact the height of the canvas unless the lockoff parameter is set to lock the height.

lockoff

This parameter determines whether to lock the width or height when calculating the canvas size. It accepts three options: "false", "w", and "h". When set to "w", the width is locked, and the height is adjusted based on the aspect ratio. When set to "h", the height is locked, and the width is adjusted based on the aspect ratio. The default value is "false".

rate

This parameter specifies the aspect ratio for the canvas in the format "width:height". It accepts a string value with a default of "1:1". This ratio is used to calculate the other dimension when one dimension is locked using the lockoff parameter.

reverse

This parameter determines whether to reverse the calculated width and height. It accepts two options: "false" and "true". When set to "true", the calculated width and height are swapped. The default value is "false".

cal size Output Parameters:

w

This output parameter represents the calculated width of the canvas after considering the input parameters and any adjustments made based on the aspect ratio and lock settings. It is an integer value.

h

This output parameter represents the calculated height of the canvas after considering the input parameters and any adjustments made based on the aspect ratio and lock settings. It is an integer value.

cal size Usage Tips:

  • To maintain a specific aspect ratio while adjusting the canvas size, set the rate parameter to your desired ratio and use the lockoff parameter to lock either the width or height.
  • If you need to swap the width and height after calculation, set the reverse parameter to "true" to easily achieve this without manually adjusting the values.

cal size Common Errors and Solutions:

Invalid aspect ratio format

  • Explanation: The rate parameter must be in the format "width:height".
  • Solution: Ensure that the rate parameter is a string in the correct format, such as "16:9" or "4:3".

Width or height out of bounds

  • Explanation: The w or h parameter values exceed the allowed range.
  • Solution: Ensure that the w and h values are within the range of 0 to 10,000,000.

Division by zero error

  • Explanation: The aspect ratio specified in the rate parameter results in a division by zero.
  • Solution: Check the rate parameter to ensure it does not contain zero values, such as "0:1" or "1:0".

cal size Related Nodes

Go back to the extension to check out more related nodes.
ymc-node-suite-comfyui
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.