ComfyUI > Nodes > ComfyUI-Addoor > Width and height from aspect ratio 🪴

ComfyUI Node: Width and height from aspect ratio 🪴

Class Name

Width and height from aspect ratio 🪴

Category
🌻 Addoor/Utilities
Author
ADDOOR (Account age: 2884days)
Extension
ComfyUI-Addoor
Latest Updated
2025-01-24
Github Stars
0.03K

How to Install ComfyUI-Addoor

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

Width and height from aspect ratio 🪴 Description

Calculate image dimensions based on aspect ratio and target size for maintaining proportions in artwork, ensuring appropriate scaling and optional adjustments for alignment.

Width and height from aspect ratio 🪴:

The "Width and height from aspect ratio 🪴" node is a utility designed to calculate the dimensions of an image based on a specified aspect ratio and a target size. This node is particularly useful for AI artists who need to maintain specific proportions in their artwork while adjusting the overall size. By providing a target size, the node ensures that the resulting dimensions are scaled appropriately, maintaining the desired aspect ratio. This functionality is essential for creating images that fit specific display or print requirements without distortion. The node also allows for optional adjustments to ensure that the dimensions are multiples of a specified value, which can be crucial for certain applications where alignment or grid fitting is necessary.

Width and height from aspect ratio 🪴 Input Parameters:

aspect_ratio

The aspect_ratio parameter defines the proportional relationship between the width and height of the image. It is specified as a string in the format "width:height", such as "16:9" or "4:3". This parameter is crucial as it dictates the shape of the resulting image. The available options include common aspect ratios like "1:1", "16:9", and "4:3", among others. The default value is "1:1", which represents a square image.

target_size

The target_size parameter specifies the desired size of the image in terms of its largest dimension, either width or height, depending on the aspect ratio. It is an integer value with a default of 1024, and it can range from a minimum of 64 to a maximum of 8192. This parameter determines the scale of the image while maintaining the specified aspect ratio.

multiple_of

The multiple_of parameter is optional and allows you to specify a value that the resulting width and height should be multiples of. This can be important for ensuring compatibility with certain systems or requirements that necessitate dimensions to be aligned to specific grid sizes. The default value is 8, with a range from 1 to 1024.

Width and height from aspect ratio 🪴 Output Parameters:

width

The width output parameter represents the calculated width of the image based on the specified aspect ratio and target size. It is an integer value that ensures the image maintains the desired proportions while fitting within the target size constraints.

height

The height output parameter represents the calculated height of the image, similar to the width, ensuring that the image maintains the specified aspect ratio. This value is also adjusted to fit within the target size constraints and is a multiple of the specified multiple_of parameter if provided.

Width and height from aspect ratio 🪴 Usage Tips:

  • To maintain a specific aspect ratio while resizing an image, choose an aspect ratio that matches your desired output and set the target size to control the overall scale.
  • Use the multiple_of parameter to ensure that the resulting dimensions are compatible with systems that require specific alignment, such as certain display technologies or printing processes.

Width and height from aspect ratio 🪴 Common Errors and Solutions:

Invalid aspect ratio format

  • Explanation: The aspect ratio must be in the format "width:height" with positive integers.
  • Solution: Ensure that the aspect ratio is correctly formatted and uses valid integer values.

Target size out of range

  • Explanation: The target size must be between 64 and 8192. - Solution: Adjust the target size to fall within the acceptable range.

Multiple of value out of range

  • Explanation: The multiple_of parameter must be between 1 and 1024.
  • Solution: Set the multiple_of parameter to a valid value within the specified range.

Width and height from aspect ratio 🪴 Related Nodes

Go back to the extension to check out more related nodes.
ComfyUI-Addoor
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.