ComfyUI > Nodes > ComfyUI > Crop Latent

ComfyUI Node: Crop Latent

Class Name

LatentCrop

Category
latent/transform
Author
ComfyAnonymous (Account age: 598days)
Extension
ComfyUI
Latest Updated
2024-08-12
Github Stars
45.85K

How to Install ComfyUI

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

Crop Latent Description

Crop specified region from latent image with precise control over parameters for focused manipulation.

Crop Latent:

The LatentCrop node is designed to crop a specified region from a latent image, which is a representation used in AI models to encode image data. This node allows you to define the exact area of the latent image you want to extract by specifying the width, height, and the starting coordinates (x, y) of the crop. This can be particularly useful for focusing on specific parts of an image, removing unwanted areas, or preparing the latent image for further processing. By providing precise control over the cropping parameters, LatentCrop helps you manipulate latent images effectively, ensuring that only the desired portion of the image is retained for subsequent operations.

Crop Latent Input Parameters:

samples

This parameter represents the latent image data that you want to crop. It is a required input and should be of the type LATENT. The latent image contains the encoded information of the original image, which the node will process to extract the specified region.

width

This parameter defines the width of the cropped region in pixels. The default value is 512, with a minimum value of 64 and a maximum value determined by the MAX_RESOLUTION constant. The width must be a multiple of 8, as indicated by the step size of 8. Adjusting this parameter allows you to control the horizontal size of the cropped area.

height

This parameter specifies the height of the cropped region in pixels. Similar to the width, the default value is 512, with a minimum value of 64 and a maximum value determined by the MAX_RESOLUTION constant. The height must also be a multiple of 8. This parameter lets you control the vertical size of the cropped area.

x

This parameter sets the x-coordinate of the top-left corner of the cropped region. The default value is 0, with a minimum value of 0 and a maximum value determined by the MAX_RESOLUTION constant. The x-coordinate must be a multiple of 8. Adjusting this parameter allows you to shift the cropped area horizontally within the latent image.

y

This parameter defines the y-coordinate of the top-left corner of the cropped region. The default value is 0, with a minimum value of 0 and a maximum value determined by the MAX_RESOLUTION constant. The y-coordinate must be a multiple of 8. This parameter lets you shift the cropped area vertically within the latent image.

Crop Latent Output Parameters:

LATENT

The output of the LatentCrop node is a cropped latent image of type LATENT. This output contains only the specified region of the original latent image, based on the width, height, x, and y parameters provided. The cropped latent image can then be used for further processing or analysis in subsequent nodes.

Crop Latent Usage Tips:

  • Ensure that the width and height parameters are set to values that are multiples of 8 to avoid errors.
  • Use the x and y parameters to precisely position the cropped area within the latent image, especially when you need to focus on a specific region.
  • Adjust the width and height parameters to match the aspect ratio of the region you want to crop, ensuring that the cropped area retains the desired proportions.

Crop Latent Common Errors and Solutions:

"x-coordinate out of bounds"

  • Explanation: The x-coordinate specified is beyond the width of the latent image.
  • Solution: Ensure that the x-coordinate plus the width of the crop does not exceed the width of the latent image. Adjust the x parameter accordingly.

"y-coordinate out of bounds"

  • Explanation: The y-coordinate specified is beyond the height of the latent image.
  • Solution: Ensure that the y-coordinate plus the height of the crop does not exceed the height of the latent image. Adjust the y parameter accordingly.

"Invalid width or height"

  • Explanation: The width or height specified is not a multiple of 8 or is outside the allowed range.
  • Solution: Ensure that both the width and height are multiples of 8 and within the range of 64 to MAX_RESOLUTION. Adjust the parameters to valid values.

Crop Latent Related Nodes

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