ComfyUI  >  Nodes  >  ComfyUI Easy Use >  ImageRatio

ComfyUI Node: ImageRatio

Class Name

easy imageRatio

Category
EasyUse/Image
Author
yolain (Account age: 1341 days)
Extension
ComfyUI Easy Use
Latest Updated
6/25/2024
Github Stars
0.5K

How to Install ComfyUI Easy Use

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

ImageRatio Description

Calculate image aspect ratio in integer and floating-point formats, simplifying proportions for AI artists.

ImageRatio:

The easy imageRatio node is designed to calculate and provide the aspect ratio of an image in both integer and floating-point formats. This node is particularly useful for AI artists who need to understand the proportions of their images for various artistic and technical purposes. By determining the greatest common factor (GCF) of the image's width and height, the node simplifies the aspect ratio to its most basic form, making it easier to work with. This can be especially beneficial when resizing images, ensuring that the proportions are maintained, or when preparing images for different formats and displays. The node's ability to return both integer and floating-point ratios provides flexibility depending on the precision required for your project.

ImageRatio Input Parameters:

image

The image parameter is the only required input for this node. It represents the image whose aspect ratio you want to calculate. The image should be provided in a format that the node can process, typically as an array or tensor with dimensions corresponding to the image's height, width, and color channels. This parameter is crucial as it directly influences the calculation of the aspect ratio. There are no specific minimum, maximum, or default values for this parameter, as it entirely depends on the image you provide.

ImageRatio Output Parameters:

width_ratio_int

The width_ratio_int output parameter represents the width component of the image's aspect ratio in its simplest integer form. This value is derived by dividing the image's width by the greatest common factor of the width and height.

height_ratio_int

The height_ratio_int output parameter represents the height component of the image's aspect ratio in its simplest integer form. This value is derived by dividing the image's height by the greatest common factor of the width and height.

width_ratio_float

The width_ratio_float output parameter represents the width component of the image's aspect ratio in floating-point form. This value is the same as width_ratio_int but expressed as a float for applications requiring decimal precision.

height_ratio_float

The height_ratio_float output parameter represents the height component of the image's aspect ratio in floating-point form. This value is the same as height_ratio_int but expressed as a float for applications requiring decimal precision.

ImageRatio Usage Tips:

  • Use the easy imageRatio node to quickly determine the aspect ratio of your images before resizing them to ensure that the proportions are maintained.
  • The integer aspect ratio outputs (width_ratio_int and height_ratio_int) are particularly useful for understanding the basic proportions of your image, while the floating-point outputs (width_ratio_float and height_ratio_float) can be used for more precise calculations.

ImageRatio Common Errors and Solutions:

Image input is None

  • Explanation: This error occurs when the image parameter is not provided or is None.
  • Solution: Ensure that you provide a valid image as input to the node. Check that the image is correctly loaded and passed to the node.

Image dimensions are invalid

  • Explanation: This error occurs when the image does not have valid dimensions (e.g., width or height is zero).
  • Solution: Verify that the image has valid dimensions and is not corrupted. Ensure that the image's width and height are greater than zero.

Division by zero error

  • Explanation: This error occurs if the greatest common factor (GCF) calculation results in zero, leading to a division by zero.
  • Solution: Ensure that the image dimensions are valid and non-zero. If the error persists, check the implementation of the GCF function for any potential issues.

ImageRatio Related Nodes

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