Image Tool icon

Image Tool

Image-related tools, including image analysis, color correction, and image compression, etc.

Overview

The node "Image Tool" provides various image-related operations, including image compression. Specifically, the Image Compress operation allows users to compress images either from a URL or from binary data within the workflow. This is useful for reducing image file sizes to optimize storage, speed up uploads/downloads, or meet size constraints for web or app usage.

Common scenarios include:

  • Automatically compressing user-uploaded images before saving them.
  • Reducing image size for faster delivery in web applications.
  • Preparing images for email attachments or social media posts with size limits.

Practical example: A user wants to compress product images fetched from URLs to ensure they do not exceed 1MB in size while maintaining acceptable quality.

Properties

Name Meaning
Output Field The name of the output buffer field where the compressed image data will be stored.
Binary File Whether the input image should be taken from a binary field (true) or from a URL (false).
URL The URL of the image to compress (used only if Binary File is false).
Input Binary Field The name of the binary field containing the image data to compress (used only if Binary File is true).
Auto Quality Whether to automatically adjust quality based on size constraints (true) or use a fixed custom quality (false).
Minimum Quality The minimum quality level (1-100) when using auto quality mode.
Maximum Quality The maximum quality level (1-100) when using auto quality mode.
Maximum Size (Bytes) The target maximum size of the compressed image in bytes when using auto quality mode.
Custom Quality The fixed quality level (1-100) to use when auto quality is disabled.
Options > Compress Effort CPU intensity of compression from 0 (fastest) to 6 (slowest), controlling compression effort and speed.

Output

The node outputs the compressed image data in a JSON field named as specified by the Output Field property (default "data"). This field contains the compressed image buffer.

If the input was binary, the output will be binary data representing the compressed image. If the input was from a URL, the output will similarly contain the compressed image data ready for further processing or saving.

Dependencies

  • The node depends on internal image processing operations bundled within the node's codebase.
  • No external API keys or services are required.
  • It requires the n8n environment to support binary data handling for image input/output.

Troubleshooting

  • Issue: Image URL is invalid or inaccessible.

    • Error: Node may throw an error indicating failure to download or process the image.
    • Resolution: Verify the URL is correct and publicly accessible.
  • Issue: Specified binary field does not exist or is empty.

    • Error: Node will fail to find the binary data to compress.
    • Resolution: Ensure the binary field name matches exactly and that the previous node outputs valid binary image data.
  • Issue: Compression settings result in poor image quality or no size reduction.

    • Error: No explicit error, but output image may be unsatisfactory.
    • Resolution: Adjust quality parameters (minQuality, maxQuality, or customQuality) and compression effort to balance quality and size.
  • Issue: Large images cause high CPU usage or slow execution.

    • Resolution: Reduce compressEffort value to speed up compression at the cost of some quality.

Links and References

Discussion