0CodeKit icon

0CodeKit

A toolbox of no-code utilities

Actions132

Image → Crop Image

AI-generated

Overview

The "Crop Image" operation of the Image resource in this node allows users to crop an image by specifying the cropping rectangle's position and size. The image can be provided either as a publicly accessible URL or as a base64-encoded buffer. This operation is useful for scenarios where you need to extract a specific portion of an image, such as focusing on a subject, removing unwanted borders, or preparing images for thumbnails or previews.

Practical examples include:

  • Cropping profile pictures uploaded by users to a fixed size.
  • Extracting a logo or watermark area from a larger image.
  • Preparing product images by cropping to highlight the product only.

Properties

Name Meaning
Data Type Choose the source type of the image: URL (publicly accessible image URL) or Buffer (base64-encoded image data).
Image URL The URL of the image to crop. Must be publicly accessible. Used only if Data Type is set to URL.
Image Buffer Base64-encoded image data to crop. Used only if Data Type is set to Buffer.
Crop Settings JSON object defining the crop rectangle with properties: top (pixels from top), left (pixels from left), width (crop width in pixels), and height (crop height in pixels). Example: {"top":50,"left":50,"width":200,"height":200}

Output

The output will contain the cropped image data. Although the exact structure is not explicitly shown in the code snippet, typically the output JSON will include the cropped image either as a URL or as base64-encoded data depending on the input type and API response.

If binary data is returned, it would represent the cropped image file content suitable for further processing or saving.

Dependencies

  • Requires an API key credential for authentication with the external 0CodeKit service.
  • The node sends a POST request to the /image/crop endpoint of the 0CodeKit API (https://prod.0codekit.com/image/crop).
  • The user must ensure that the image URL is publicly accessible if using the URL option.
  • No additional local dependencies are required; all processing is done via the external API.

Troubleshooting

  • Image URL inaccessible: If the image URL is not publicly accessible or returns an error, the crop operation will fail. Ensure the URL is reachable without authentication.
  • Invalid base64 data: When using the buffer option, invalid or corrupted base64 strings will cause errors. Verify the base64 encoding is correct.
  • Incorrect crop dimensions: Specifying crop coordinates outside the bounds of the image may result in errors or unexpected results. Double-check the top, left, width, and height values.
  • API authentication errors: Missing or invalid API credentials will prevent the request from succeeding. Confirm the API key is correctly configured in n8n credentials.
  • Malformed JSON in Crop Settings: The crop settings must be valid JSON. Invalid JSON syntax will cause the node to error out.

Links and References


This summary is based solely on static analysis of the provided source code and property definitions.

Discussion