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 provides an image compression operation that reduces the file size of images while maintaining acceptable quality. It supports multiple input methods for providing the image to compress, including binary data from a previous node, base64-encoded strings, or direct URLs to image files. The node outputs a compressed image in either JPG or PNG format with configurable compression levels.

Common scenarios where this node is beneficial include:

  • Optimizing images before uploading them to websites or cloud storage to save bandwidth and storage costs.
  • Preparing images for email attachments or messaging platforms where file size limits apply.
  • Automating image processing workflows where images need to be resized or compressed before further use.

Practical example:

  • A user receives images from various sources and wants to compress them automatically before saving to a database or sending via API. They can feed the images as binary data or URLs into this node, select the desired compression level and output format, and get back optimized images ready for downstream processing.

Properties

Name Meaning
Input Image Data Type Choose how to provide the image file to compress: "Binary Data" (from previous node), "Base64 String" (base64 encoded content), or "URL" (link to image).
Input Binary Field Name of the binary property containing the image file (used only if Input Image Data Type is "Binary Data"). Default is "data".
Base64 Image Content Base64 encoded string of the image content (used only if Input Image Data Type is "Base64 String").
Image URL URL pointing to the image file (used only if Input Image Data Type is "URL").
Output File Name Desired filename for the compressed image output. Default is "compressed_image.jpg".
Image Type Output format for the compressed image: "JPG" or "PNG".
Compression Level Compression intensity: "Max", "Medium", or "Low".
Binary Data Output Name Custom name for the binary data field in the node's output. Default is "data".

Output

The node outputs the compressed image as binary data under the specified binary data output name (default "data"). The output includes:

  • json: Metadata about the processed item (usually minimal or empty).
  • binary: Contains the compressed image file data with the chosen filename and MIME type corresponding to the selected image format (JPG or PNG).

This allows subsequent nodes in the workflow to access the compressed image directly for further processing, storage, or transmission.

Dependencies

  • The node requires internet access if using the "URL" input option to fetch the image.
  • No explicit external API keys or credentials are required based on the provided code.
  • The node relies on internal image compression libraries or services bundled within the implementation (not detailed in the source).

Troubleshooting

  • Common issues:

    • Providing an invalid or inaccessible URL when using the URL input type will cause failures fetching the image.
    • Incorrect base64 strings may result in decoding errors.
    • Specifying a non-existent binary property name when using binary data input will cause the node to fail to find the image.
    • Unsupported image formats or corrupted image data might lead to compression errors.
  • Error messages and resolutions:

    • "Image not found in binary property": Verify the binary property name matches the actual input data.
    • "Failed to fetch image from URL": Check the URL accessibility and correctness.
    • "Invalid base64 image content": Ensure the base64 string is properly encoded without extra characters.
    • Compression errors: Try lowering the compression level or changing the output image type.

Enabling "Continue On Fail" in the node settings can help workflows proceed even if some items fail compression.

Links and References

Discussion