Skip to main content

Crop Image

Crops an image to a specified rectangular region defined by coordinates and dimensions.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • In Path - Path to the input image file.
  • X Coordinate - X coordinate of the top-left corner of the crop area.
  • Y Coordinate - Y coordinate of the top-left corner of the crop area.
  • Width - Width of the crop area in pixels.
  • Height - Height of the crop area in pixels.
  • Out Path - Path where the cropped output image will be saved.

Options

This node does not have any configurable options.

Output

  • result - Boolean indicating success or failure of the crop operation.

How It Works

The Crop Image node uses ImageMagick library to extract a rectangular portion of an image. When executed, the node:

  1. Validates input and output file paths
  2. Loads the specified input image
  3. Validates crop coordinates and dimensions against the image size
  4. Automatically adjusts crop dimensions if they exceed image boundaries
  5. Extracts the specified rectangular region from the image
  6. Saves the cropped image to the output path

Requirements

  • Valid input image file at the specified path
  • Output path must be writable
  • Valid numeric values for coordinates and dimensions
  • Coordinates must be within the image boundaries

Error Handling

The node will return specific errors in the following cases:

  • Empty or invalid input file path
  • Input file not found at the specified path
  • Empty or invalid output file path
  • X coordinate larger than the image width
  • Y coordinate larger than the image height

Usage Notes

  • Coordinate system starts from the top-left corner (0,0)
  • If the specified crop area extends beyond image boundaries, the node automatically adjusts the crop dimensions to fit within the image
  • The output image will have the dimensions specified by the Width and Height parameters (after adjustment if necessary)
  • Processing time is generally fast since only a portion of the image is processed
  • Cropping does not affect image quality as it's a lossless operation
  • The node preserves image metadata in the cropped output
  • For best results, ensure coordinates and dimensions are appropriate for the source image size