Compress Image using n8n action
PDF4me Compress Image reduces image file sizes while maintaining optimal visual quality through n8n automation workflows. Process images via n8n triggers, binary data, base64 strings, or public URLs to compress JPG or PNG images with selectable compression levels (Low, Medium, High), intelligent quality optimization, format-specific algorithms, and file size reduction up to 85% while preserving essential image quality. This solution is ideal for web optimization, storage efficiency, bandwidth reduction, email attachments, mobile app optimization, and automated image compression workflows that require balanced file size reduction with maintained quality and seamless integration.
Setup
Add the PDF4me "Compress Image" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.
Prerequisites:
- PDF4me API credentials
- n8n workflow access
Configuration:
- Add PDF4me node to workflow
- Select "Compress Image" action
- Configure input parameters (see below)

Parameters
Complete list of parameters for the Compress Image action. Configure these parameters to control image compression.
Important: Parameters marked with an asterisk (***) are required and must be provided for the action to function correctly.
| Parameter | Type | Description | Example |
|---|---|---|---|
| Input Image Data Type | String | Yes | PDF4me image input format selection Choose the format of your source image data input. PDF4me supports multiple input types with different field requirements |
| 1) Binary Data | Yes (One Required) | 1) Binary Data - Use "Input Binary Field" to reference image file from previous node | |
| 2) Base64 String | Yes (One Required) | 2) Base64 String - Use "Base64 Image Content" field for encoded image data | |
| 3) URL | Yes (One Required) | 3) URL - Use "Image URL" field to provide a public/open permission URL to the image file to compress | |
| Input Binary Field | Binary | Yes (If Binary Data) | PDF4me binary image file input - Reference source image file (.jpg, .png, .gif, .bmp) from previous n8n node or file upload. PDF4me processes binary image files with automatic format detection and validation. Required when Input Image Data Type is "Binary Data" |
| Base64 Image Content | String | Yes (If Base64 String) | PDF4me base64 encoded image input - Provide source image data (.jpg, .png, .gif, .bmp) as base64 encoded string for secure transmission. PDF4me automatically decodes and processes the image content. Required when Input Image Data Type is "Base64 String" |
| Image URL | String | Yes (If URL) | PDF4me public image URL input - Provide a public/open permission URL to the source image file (.jpg, .png, .gif, .bmp) to be compressed. PDF4me downloads and processes the file from the provided URL. Required when Input Image Data Type is "URL" |
| Image Type | String | Yes | PDF4me output format selection - Choose the desired output format for the compressed image. PDF4me supports multiple formats with different compression characteristics and quality levels |
| JPG | Yes (One Required) | JPEG Format - Joint Photographic Experts Group format with lossy compression, ideal for photographs and complex images with excellent file size reduction | |
| PNG | Yes (One Required) | PNG Format - Portable Network Graphics format with lossless compression, ideal for graphics with transparency and sharp edges | |
| Compression Level | String | Yes | PDF4me compression intensity - Choose the compression level that balances file size reduction with image quality. Higher compression reduces file size more but may affect image quality. Low (10-30% reduction, minimal quality loss) for high-quality requirements and professional printing. Medium (30-60% reduction, moderate quality loss) for general web use, social media, and standard applications. High (60-85% reduction, noticeable quality loss) for bandwidth optimization, storage efficiency, and thumbnails |
| Low | Yes (One Required) | Low Compression - Minimal file size reduction with maximum quality preservation. Ideal for high-quality requirements and minimal quality loss | |
| Medium | Yes (One Required) | Medium Compression - Balanced file size reduction with good quality preservation. Ideal for general use and web optimization | |
| High | Yes (One Required) | High Compression - Maximum file size reduction with acceptable quality. Ideal for bandwidth optimization and storage efficiency | |
| Output File Name | String | Yes | PDF4me output filename configuration - Specify the name for the generated compressed image file with proper extension (.jpg, .png, .gif, .bmp). This is an input parameter that configures what the output file will be named. PDF4me ensures unique naming and validates file format compliance |
| Binary Data Output Name | String | Yes | PDF4me output variable configuration - Define the variable name for accessing the generated compressed image binary data in your n8n workflow. This is an input parameter that configures how the output data will be accessible. This binary data can be used as input data in subsequent actions within your workflow |
Supported Image Formats
| Format | Description | File Extensions | Max Size | Compression Type | Best Use Cases |
|---|---|---|---|---|---|
| JPEG | Joint Photographic Experts Group with lossy compression optimized for photographs | .jpg, .jpeg | 50MB | Lossy | Photographs, complex images, web content, social media |
| PNG | Portable Network Graphics with lossless compression and transparency support | .png | 50MB | Lossless | Graphics with transparency, logos, screenshots, web graphics |
Output
Output Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| fileName | String | PDF4me generated image filename - The complete filename of the successfully compressed image with proper extension. PDF4me ensures unique naming and validates file format compliance for seamless integration with downstream processes | compressed_image.jpg |
| fileSize | Number | PDF4me compressed image file size in bytes - The exact size of the generated compressed image file in bytes, provided by PDF4me for storage planning, bandwidth optimization, and file transfer monitoring. Essential for enterprise image management and workflow automation | 125430 |
| originalFileSize | Number | PDF4me original file size in bytes - The size of the original image file before compression, provided for comparison and compression ratio calculation | 245760 |
| compressionRatio | Number | PDF4me compression efficiency - The percentage of file size reduction achieved through compression, calculated as ((originalFileSize - fileSize) / originalFileSize) * 100 | 49.1 |
| success | Boolean | PDF4me compression status indicator - Boolean flag indicating the success or failure of the image compression process. PDF4me returns true for successful operations and false for any errors, enabling robust error handling in automated workflows | true |
| mimeType | String | PDF4me output MIME type - MIME type of the generated compressed image file (e.g., "image/jpeg", "image/png"). Useful for content type validation and proper file handling in web applications | image/jpeg |
| message | String | PDF4me compression status message - Human-readable status message providing details about the image compression process result. Includes success confirmation or error details for troubleshooting | Image compressed successfully |
N8N Action Response
The PDF4me Compress Image API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:
- JSON
- Table
- Schema
- Binary
JSON Response Format
The raw JSON response from the API:
[
{
"success": true,
"message": "Image compressed successfully",
"fileName": "compressed_image.jpg",
"mimeType": "image/jpeg",
"fileSize": 125430,
"originalFileSize": 245760,
"compressionRatio": 49.1
}
]
Table View
Response data in a structured table format:
| Parameter | Value |
|---|---|
| success | true |
| message | Image compressed successfully |
| fileName | compressed_image.jpg |
| mimeType | image/jpeg |
| fileSize | 125430 |
| originalFileSize | 245760 |
| compressionRatio | 49.1 |
Schema View
The data structure and types of the response:
1 item
success: ☑ true
message: AB Image compressed successfully
fileName: AB compressed_image.jpg
mimeType: AB image/jpeg
fileSize: # 125430
originalFileSize: # 245760
compressionRatio: # 49.1
Type Indicators:
AB= String#= Number☑= Boolean
Binary Data View
The actual compressed image file data and metadata:
data
─────────────────────────────
File Name: compressed_image.jpg
File Extension: jpg
Mime Type: image/jpeg
File Size: 122.5 KB
Binary Data Access:
- n8n Binary Object:
$binary.data.data - Base64 Content: Available for direct use
- File Operations: Ready for download, email, or storage
Use Cases
Web Performance Optimization
- Compress images for faster website loading and improved user experience
- Optimize images for mobile devices and bandwidth-constrained environments
- Reduce server storage costs and bandwidth usage for web applications
Content Management and Storage
- Batch compress large image collections for efficient storage management
- Optimize images for content management systems and digital asset libraries
- Reduce backup storage requirements and improve data transfer efficiency
E-commerce and Marketing
- Optimize product images for online stores and marketplaces
- Compress marketing materials for email campaigns and social media
- Create multiple image sizes for responsive web design and mobile apps
Enterprise Image Processing
- Standardize image optimization across multiple departments and workflows
- Implement automated compression for document management systems
- Optimize images for enterprise applications and internal tools