n8n custom node to compress images using sharp
npm install n8n-nodes-image-compress!n8n Image Compress - before and after
Compress and optionally resize images in n8n using sharp. Optimizing image size is one of the highest-impact improvements you can make for performance and SEO:
- Smaller images load faster, improving Core Web Vitals (especially Largest Contentful Paint) and search rankings.
- Faster pages reduce bounce rates and increase conversion.
- Lower bandwidth and storage costs across your pipelines and destinations (websites, CDNs, storage buckets).
- Quicker uploads and API calls in automations that handle user-generated content.
sharp) to perform image compression and resizing. As a result:sharp bundles libvips for most platforms.Learn more: n8n verification criteria — https://docs.n8n.io/integrations/community-nodes/build-community-nodes/#submit-your-node-for-verification-by-n8n
To install a custom node in n8n, follow these steps:
- Refer to the official documentation: n8n Custom Node Installation
- Choose the custom node you want to install, for example, n8n-nodes-image-compress.
- Follow the instructions provided in the documentation to install and configure the custom node.
For detailed installation steps and configuration options, please visit the official n8n documentation linked above.
1. Add the "Compress Image" node to your workflow.
2. Choose Input Source:
- Binary Property: set the binary property name (default: data).
- Base64 Field (JSON): set the field containing a Base64 string (data URL prefix is supported).
3. Select Output Format: jpg, png, webp, or avif.
4. Set Quality (0–100, default 80). Applies to JPEG/WebP/AVIF. PNG maps quality to compressionLevel.
5. Strip Metadata (default on) to remove EXIF/ICC for smaller files; disable to preserve metadata.
6. Optional Resize:
- Provide width and/or height. With "Maintain Aspect Ratio" on, dimensions act as a bounding box (fit: inside).
- The node won’t enlarge small images by default.
7. Output Binary Property: choose where the compressed image is stored (default: data).
8. Run the node. The output includes:
- A compressed image in the specified binary property.
- JSON metadata with compression.originalSize, compression.newSize, and compression.percentReduction.
!n8n Image Compress - usage screenshot
compression.originalSize, compression.newSize, compression.percentReductionStrip Metadata to preserve EXIF/ICC..rotate().compressionLevel (0–9) in sharp.
Brought to you by the friendly developers of DevToolsHub : https://www.devtoolskithub.com/
Your all-in-one developer toolkit. Format JSON, test regex patterns, decode JWTs, compress images, and more. Free developer tools with premium features.