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

The node provides an image cropping functionality as part of a broader PDF and image processing suite. Specifically, the "Crop Image" operation allows users to crop images by either removing borders or selecting a specific rectangular area within the image. This is useful in scenarios where you need to trim unwanted edges from images, focus on a particular section, or prepare images for further processing or presentation.

Practical examples include:

  • Automatically trimming white or colored borders from scanned documents.
  • Extracting a region of interest from photos or screenshots.
  • Preparing images for thumbnails by cropping to a fixed rectangle.

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 representing 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 specified pixels from each border), Rectangle (crop to a defined rectangular area).
Border Cropping Options Collection of options specifying number of pixels to crop from each side: Left Border, Right Border, Top Border, Bottom Border.
Rectangle Cropping Options Collection of options defining the rectangle to crop: Upper Left X and Y coordinates, Width, Height (all in pixels).
Output Binary Field Name Name of the binary property where the cropped image file will be stored.
Advanced Options Optional JSON string to specify custom profiles or additional API call options for advanced use cases.

Output

The node outputs the cropped image as binary data under a user-defined binary property name (default is "data"). The output includes the cropped image file ready for downstream nodes to consume or save. The output JSON also contains metadata such as the filename.

If the input was provided as base64 or URL, the node converts it internally to binary before cropping and outputs the cropped image similarly as binary data.

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 example, if using binary data, verify the binary property name matches the actual input.
  • Cropping parameters out of bounds: If cropping dimensions exceed the image size, errors may occur. Adjust border sizes or rectangle coordinates to fit within the image dimensions.
  • Network issues: When providing image URLs or calling external APIs, network connectivity problems can cause failures.
  • API errors: Check that API keys are valid and have sufficient permissions. Review error messages returned by the API for guidance.
  • Unsupported image formats: Confirm the input image format is supported by the cropping service.

Links and References

Discussion