ComfyUI > Nodes > CRT-Nodes > Image Dimensions From Megapixels (CRT)

ComfyUI Node: Image Dimensions From Megapixels (CRT)

Class Name

ImageDimensionsFromMegaPixels

Category
CRT/Image
Author
CRT (Account age: 1707days)
Extension
CRT-Nodes
Latest Updated
2026-03-16
Github Stars
0.1K

How to Install CRT-Nodes

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

Image Dimensions From Megapixels (CRT) Description

Calculates optimal image dimensions from megapixels, preserving aspect ratio and allowing size adjustments.

Image Dimensions From Megapixels (CRT):

The ImageDimensionsFromMegaPixels node is designed to calculate the optimal width and height for an image based on a specified megapixel target. This node is particularly useful for AI artists who need to resize images while maintaining a specific resolution quality. By leveraging the aspect ratio of the original image, the node ensures that the resized dimensions are proportionate, thus preserving the visual integrity of the image. The node also allows for the dimensions to be adjusted to be a multiple of a specified integer, which can be crucial for certain applications that require dimensions to align with specific grid sizes or processing requirements. This functionality is essential for artists looking to optimize their images for various outputs without manually calculating the dimensions.

Image Dimensions From Megapixels (CRT) Input Parameters:

image

The image parameter represents the input image that you want to resize. It is crucial as it provides the original dimensions and aspect ratio, which are used to calculate the new dimensions. This parameter does not have a minimum or maximum value as it is dependent on the image you provide.

megapixels

The megapixels parameter specifies the target resolution in terms of megapixels for the resized image. It determines the total number of pixels the output image should have, with 1.0 megapixel being equivalent to 1,000,000 pixels. The minimum value is 0.1, the maximum is 200.0, and the default is 1.0. Adjusting this value allows you to control the level of detail and quality in the resized image.

multiple_of

The multiple_of parameter ensures that the calculated dimensions are rounded to be a multiple of a specified integer. This is particularly useful for applications that require images to have dimensions that are multiples of a certain number, such as 16 or 32, to align with processing requirements. The minimum value is 1, the maximum is 512, and the default is 16. This parameter helps maintain compatibility with various image processing tools and frameworks.

Image Dimensions From Megapixels (CRT) Output Parameters:

width

The width output parameter provides the calculated width of the resized image in pixels. It is determined based on the target megapixels and the aspect ratio of the original image, ensuring that the resized image maintains its visual proportions. This value is adjusted to be a multiple of the specified multiple_of parameter, if applicable.

height

The height output parameter provides the calculated height of the resized image in pixels. Similar to the width, it is calculated to maintain the aspect ratio and is adjusted to be a multiple of the specified multiple_of parameter. This ensures that the resized image is proportionate and compatible with specific processing requirements.

Image Dimensions From Megapixels (CRT) Usage Tips:

  • To maintain the original aspect ratio while resizing, ensure that the megapixels parameter is set according to the desired resolution quality, and use the multiple_of parameter to align with specific processing needs.
  • When working with applications that require specific dimension multiples, adjust the multiple_of parameter to match those requirements, such as setting it to 32 for compatibility with certain neural networks.

Image Dimensions From Megapixels (CRT) Common Errors and Solutions:

Invalid image shape

  • Explanation: This error occurs when the input image does not have the expected shape or dimensions, which are necessary for calculating the aspect ratio and resizing.
  • Solution: Ensure that the input image is correctly formatted and has the necessary dimensions. Check that the image is loaded properly and conforms to the expected input format.

Megapixels out of range

  • Explanation: This error arises when the megapixels parameter is set outside the allowed range of 0.1 to 200.0.
  • Solution: Adjust the megapixels parameter to fall within the specified range. Ensure that the value is appropriate for the desired resolution quality.

Multiple_of value too high

  • Explanation: This error can occur if the multiple_of parameter is set to a value that is too high, resulting in dimensions that are not feasible for the target resolution.
  • Solution: Reduce the multiple_of parameter to a more reasonable value that allows for feasible dimension calculations while still meeting processing requirements.

Image Dimensions From Megapixels (CRT) Related Nodes

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

Image Dimensions From Megapixels (CRT)