Skip to main content

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:

  1. Add PDF4me node to workflow
  2. Select "Compress Image" action
  3. Configure input parameters (see below)
Compress Image

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.

ParameterTypeDescriptionExample
Input Image Data TypeStringYesPDF4me image input format selection
Choose the format of your source image data input.
PDF4me supports multiple input types with different field requirements
1) Binary DataYes (One Required)1) Binary Data - Use "Input Binary Field" to reference image file from previous node
2) Base64 StringYes (One Required)2) Base64 String - Use "Base64 Image Content" field for encoded image data
3) URLYes (One Required)3) URL - Use "Image URL" field to provide a public/open permission URL to the image file to compress
Input Binary FieldBinaryYes (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 ContentStringYes (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 URLStringYes (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 TypeStringYesPDF4me output format selection - Choose the desired output format for the compressed image. PDF4me supports multiple formats with different compression characteristics and quality levels
JPGYes (One Required)JPEG Format - Joint Photographic Experts Group format with lossy compression, ideal for photographs and complex images with excellent file size reduction
PNGYes (One Required)PNG Format - Portable Network Graphics format with lossless compression, ideal for graphics with transparency and sharp edges
Compression LevelStringYesPDF4me 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
LowYes (One Required)Low Compression - Minimal file size reduction with maximum quality preservation. Ideal for high-quality requirements and minimal quality loss
MediumYes (One Required)Medium Compression - Balanced file size reduction with good quality preservation. Ideal for general use and web optimization
HighYes (One Required)High Compression - Maximum file size reduction with acceptable quality. Ideal for bandwidth optimization and storage efficiency
Output File NameStringYesPDF4me 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 NameStringYesPDF4me 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

FormatDescriptionFile ExtensionsMax SizeCompression TypeBest Use Cases
JPEGJoint Photographic Experts Group with lossy compression optimized for photographs.jpg, .jpeg50MBLossyPhotographs, complex images, web content, social media
PNGPortable Network Graphics with lossless compression and transparency support.png50MBLosslessGraphics with transparency, logos, screenshots, web graphics

Output

Output Parameters

ParameterTypeDescriptionExample
fileNameStringPDF4me 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 processescompressed_image.jpg
fileSizeNumberPDF4me 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 automation125430
originalFileSizeNumberPDF4me original file size in bytes - The size of the original image file before compression, provided for comparison and compression ratio calculation245760
compressionRatioNumberPDF4me compression efficiency - The percentage of file size reduction achieved through compression, calculated as ((originalFileSize - fileSize) / originalFileSize) * 10049.1
successBooleanPDF4me 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 workflowstrue
mimeTypeStringPDF4me 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 applicationsimage/jpeg
messageStringPDF4me compression status message - Human-readable status message providing details about the image compression process result. Includes success confirmation or error details for troubleshootingImage 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 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
}
]

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

Get Help