Overview
This node performs image cropping operations, allowing users to crop images by either removing borders or selecting a specific rectangular area. It supports multiple input formats for the image, including binary data from previous nodes, base64-encoded strings, or local file paths. This flexibility makes it useful in workflows where images need to be programmatically trimmed or resized before further processing or storage.
Common scenarios include:
- Automatically trimming whitespace or unwanted borders from scanned documents or photos.
- Extracting a specific region of interest from an image, such as cropping a face or object.
- Preparing images for thumbnails or previews by cropping to fixed dimensions.
Practical example:
- A user receives images from an upload node and wants to remove 10 pixels from each border to clean up the edges before saving them.
- Another user has base64-encoded images and wants to crop a 50x50 pixel rectangle starting at coordinates (10,10) for profile picture thumbnails.
Properties
| Name | Meaning |
|---|---|
| Input Data Type | Choose how to provide the image file to crop: • Binary Data (image from previous node) • Base64 String (base64 encoded image content) • File Path (local file path to image) |
| Input Binary Field | Name of the binary property containing the image file (used only if Input Data Type is Binary Data). |
| Base64 Image Content | Base64 encoded image content (used only if Input Data Type is Base64 String). |
| Local File Path | Local file path to the image file to crop (used only if Input Data Type is File Path). |
| Output File Name | Name for the output cropped image file (e.g., "cropped_image.jpg"). |
| Document Name | Name of the source image file for reference (e.g., "image.jpg"). |
| Crop Type | Type of cropping to perform: • Border (crop by removing borders from all sides) • Rectangle (crop to a specific rectangular area) |
| Border Cropping Options | When Crop Type is Border, specify number of pixels to crop from each side: • Left Border • Right Border • Top Border • Bottom Border |
| Rectangle Cropping Options | When Crop Type is Rectangle, specify the cropping rectangle: • Upper Left X coordinate • Upper Left Y coordinate • Width • Height |
| Advanced Options | Custom JSON profiles for advanced API options, e.g., setting output data format. Users can refer to external API documentation for supported properties. |
Output
The node outputs the cropped image data in JSON format. The exact structure depends on the input and options but generally includes:
- The cropped image content, typically as binary data attached to the output item under a specified binary property.
- Metadata fields such as the output file name and document name for reference.
If the node handles binary data, the output will contain the cropped image as binary data suitable for downstream nodes that process files or images.
Dependencies
- Requires access to an image processing API or library capable of cropping images based on the provided parameters.
- May require an API key or authentication token configured in n8n credentials to interact with the external service performing the cropping.
- Local file path input requires the node to have access permissions to the specified file system location.
Troubleshooting
- Invalid input data: If the input image data is missing or incorrectly specified (e.g., wrong binary field name or invalid base64 string), the node may fail. Ensure the input matches the selected Input Data Type.
- File not found: When using a local file path, verify the path is correct and accessible by the n8n instance.
- Crop dimensions out of bounds: Specifying crop sizes or coordinates larger than the image dimensions may cause errors or unexpected results. Validate crop parameters before execution.
- API errors: If the node relies on an external API, network issues or invalid credentials can cause failures. Check API keys and connectivity.
- Unsupported image formats: Some image types might not be supported by the cropping service; convert images to supported formats beforehand.
Links and References
- PDF4me API Documentation — For advanced profile options and additional cropping parameters.
- General image cropping concepts: https://en.wikipedia.org/wiki/Cropping_(image)