Overview
This node compresses, converts, and optionally resizes images in various formats including JPEG, PNG, WebP, and AVIF. It supports input images either as binary data or as Base64-encoded strings within JSON fields. The node is useful for optimizing image sizes to reduce storage space or bandwidth usage while maintaining acceptable visual quality. Common scenarios include preparing images for web delivery, reducing file size before uploading to cloud storage, or converting images to a preferred format.
For example, you can use this node to:
- Compress large product photos before sending them to an e-commerce platform.
- Convert user-uploaded images from PNG to WebP to improve website loading speed.
- Resize profile pictures to specific dimensions while preserving aspect ratio.
Properties
| Name | Meaning |
|---|---|
| Input Source | Where to read the input image from. Options: "Binary Property" (image data stored as binary) or "Base64 Field (JSON)" (image data encoded as Base64 string in a JSON field). |
| Binary Property | Name of the binary property to read the input image from (used if Input Source is "Binary Property"). |
| Base64 Field | Name of the JSON field containing the Base64-encoded image (used if Input Source is "Base64 Field (JSON)"). |
| Output Binary Property | Name of the binary property where the compressed image will be stored. |
| Output Format | Desired output image format. Options: JPEG, PNG, WebP, AVIF. |
| Strip Metadata | Whether to remove EXIF/ICC metadata from the image to reduce file size. Enable to strip metadata (default true), disable to preserve it. |
| Quality | Image quality level from 0 to 100. For JPEG/WebP/AVIF controls compression quality; for PNG it maps to compression level. |
| Resize | Collection of resize options: - Width: target width in pixels (0 to ignore) - Height: target height in pixels (0 to ignore) - Maintain Aspect Ratio: whether to keep aspect ratio when resizing (default true) |
| Max Input Size (MB) | Maximum allowed input image size in megabytes. Images larger than this will be rejected to avoid excessive memory usage. Default is 25 MB. |
Output
The node outputs items with the following structure:
json: Contains the original JSON data plus a newcompressionobject with details about the compression:originalSize: Original image size in bytes.newSize: Compressed image size in bytes.percentReduction: Percentage reduction in size.format: Output image format used.
binary: Contains the compressed image stored under the specified output binary property name. This binary data represents the compressed and optionally resized image in the chosen format.
Dependencies
- Uses the
sharplibrary for image processing (compression, conversion, resizing). - No external API keys or services are required.
- Requires Node.js environment capable of running native modules (
sharp).
Troubleshooting
Error: No binary data found under property "X"
Occurs if the specified binary property does not exist on the input item. Ensure the input contains the expected binary data under the correct property name.Error: Field "X" must contain a Base64 string
Happens when the Base64 field is missing or empty. Verify that the input JSON has the correct field with a valid Base64-encoded image string.Error: Input image is too large (N bytes). Max allowed is M bytes.
The input image exceeds the configured maximum size. Increase the "Max Input Size (MB)" property or provide smaller images.If the output image looks distorted after resizing, check the resize options and whether "Maintain Aspect Ratio" is enabled.
Memory issues may arise with very large images; consider lowering the max input size or resizing images earlier in the workflow.
Links and References
- Sharp GitHub Repository — Documentation for the underlying image processing library used by this node.