PDF4me icon

PDF4me

Comprehensive PDF and document processing: generate barcodes, convert files, extract data, manipulate images, and automate workflows with the PDF4ME API

Actions80

Overview

This node performs image cropping operations on input images. It supports cropping by removing borders or cropping to a specific rectangular area within the image. This functionality is useful in workflows where images need to be trimmed, resized, or focused on a particular section before further processing or storage.

Common scenarios include:

  • Removing unwanted margins or whitespace from scanned documents or photos.
  • Extracting a specific region of interest from an image for analysis or display.
  • Preparing images for thumbnails or previews by cropping to fixed dimensions.

For example, you can crop a photo by specifying how many pixels to remove from each border, or define a rectangle area by coordinates and size to extract a portion of the image.

Properties

Name Meaning
Input Data Type Choose how to provide the image file to crop. Options: Binary Data (image from previous node), Base64 String (base64 encoded image content), URL (link to image file).
Input Binary Field Name of the binary property containing the image file (used when Input Data Type is Binary Data).
Base64 Image Content Base64 encoded string of the image content (used when Input Data Type is Base64 String).
Image URL URL pointing to the image file to crop (used when Input Data Type is URL).
Output File Name Desired name for the output cropped image file.
Document Name Name of the source image file for reference purposes.
Crop Type Type of cropping to perform. Options: 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 Left, Right, Top, and Bottom borders.
Rectangle Cropping Options When Crop Type is Rectangle, specify the X and Y coordinates of the upper left corner of the crop rectangle, plus its Width and Height in pixels.
Advanced Options Custom profiles as JSON string to adjust extra properties for API calls, e.g., output data format. Reference available profiles at https://developer.pdf4me.com/api/profiles/index.html

Output

The node outputs the cropped image data in JSON format. The output includes the cropped image file, typically as binary data suitable for further processing or saving. The output file will have the specified output file name.

If the input was provided as binary data, base64 string, or URL, the output will consistently represent the cropped image in a binary form ready for downstream nodes.

Dependencies

  • Requires access to an external image processing API or service capable of performing cropping operations.
  • Needs appropriate API authentication credentials configured in n8n to authorize requests.
  • Network access is required if using image URLs or calling external APIs.

Troubleshooting

  • Invalid input data: Ensure the input image is correctly provided according to the selected Input Data Type. For binary data, verify the binary field name matches the actual input. For base64 or URL, ensure valid strings/URLs.
  • Crop dimensions out of bounds: If cropping coordinates or border sizes exceed the image dimensions, errors may occur. Verify that crop values are within the image size limits.
  • API authentication errors: Confirm that the API key or authentication token is properly set up in n8n credentials.
  • Network issues: When using image URLs or external API calls, network connectivity problems can cause failures.
  • Unsupported image formats: Some image types might not be supported by the cropping service; convert images beforehand if needed.

Links and References

Discussion