ComfyUI > Nodes > ComfyUI Fictiverse Nodes > Clamp Images To Megapixels

ComfyUI Node: Clamp Images To Megapixels

Class Name

Clamp Images To Megapixels

Category
Fictiverse/Resize
Author
Fictiverse (Account age: 1343days)
Extension
ComfyUI Fictiverse Nodes
Latest Updated
2026-04-26
Github Stars
0.02K

How to Install ComfyUI Fictiverse Nodes

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

Clamp Images To Megapixels Description

Adjusts image sizes to specified megapixel limits, preserving aspect ratio and optimizing efficiency.

Clamp Images To Megapixels:

The "Clamp Images To Megapixels" node is designed to adjust the size of images based on specified megapixel constraints, ensuring that images fall within a defined range of pixel counts. This node is particularly useful for maintaining consistency in image sizes, which can be crucial for various applications such as batch processing or preparing images for specific display requirements. By clamping images to a minimum and maximum megapixel value, this node helps in optimizing storage and processing efficiency while preserving the aspect ratio of the images. The node intelligently resizes images by calculating the target dimensions that adhere to the specified megapixel limits and rounds them to a specified multiple, ensuring that the resized images are compatible with downstream processes that may require specific dimension multiples.

Clamp Images To Megapixels Input Parameters:

images

This parameter represents the batch of images to be processed. The images are expected to be in a tensor format with dimensions [B, H, W, C], where B is the batch size, H is the height, W is the width, and C is the number of color channels. The node will adjust the size of these images based on the specified megapixel constraints.

min_mp

This parameter sets the minimum megapixel value for the images. If an image's pixel count is below this threshold, it will be resized to meet this minimum requirement. The value is specified in megapixels, where 1 megapixel equals 1,000,000 pixels. This ensures that images are not too small for the intended use, maintaining a baseline quality and detail.

max_mp

This parameter defines the maximum megapixel value for the images. If an image's pixel count exceeds this threshold, it will be resized to fit within this limit. This helps in controlling the file size and processing load, ensuring that images do not exceed the desired resolution.

multiple_of

This parameter specifies the multiple to which the new dimensions of the images should be rounded. By rounding the dimensions to a specified multiple, the node ensures compatibility with systems or processes that require images to have dimensions that are multiples of a certain value. This can be particularly useful for applications that involve grid-based layouts or specific hardware requirements.

Clamp Images To Megapixels Output Parameters:

resized_images

The output is a batch of resized images that have been adjusted to fit within the specified megapixel constraints. The images are returned in the same tensor format [B, H, W, C] as the input, ensuring compatibility with subsequent processing steps. The resized images maintain the original aspect ratio and are rounded to the specified multiple, providing a balance between size constraints and visual fidelity.

Clamp Images To Megapixels Usage Tips:

  • To maintain image quality while ensuring size constraints, set the min_mp and max_mp parameters according to the desired resolution range for your project.
  • Use the multiple_of parameter to ensure that the resized images are compatible with specific requirements, such as those needed for machine learning models or display systems that require dimensions to be multiples of a certain value.

Clamp Images To Megapixels Common Errors and Solutions:

Image size not changing

  • Explanation: This occurs when the calculated new dimensions are the same as the original dimensions, meaning the image already fits within the specified megapixel constraints.
  • Solution: Verify the min_mp and max_mp values to ensure they are set correctly. Adjust them if necessary to achieve the desired resizing effect.

Invalid multiple_of value

  • Explanation: The multiple_of parameter is set to a value that is not suitable for the image dimensions, causing rounding issues.
  • Solution: Ensure that the multiple_of value is a reasonable divisor of the image dimensions to avoid rounding errors. Adjust the value to better fit the typical dimensions of your images.

Clamp Images To Megapixels Related Nodes

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