Scheduled Google Drive Image Compression with Tinify and Email Reports - n8n Workflow

Set up an n8n workflow to automatically compress images in Google Drive using the Tinify API, move originals to an archive, log savings, and send daily reports via Gmail. Explore this powerful n8n template for file optimization.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Digital agencies or webmasters needing to optimize large batches of images for faster loading speeds.
Users looking for advanced examples of integrating external APIs (like Tinify) within an n8n workflow.
Technical users wanting to automate cloud storage file operations (Google Drive) and detailed logging using n8n templates.
Developers seeking a reliable, scheduled n8n trigger for daily maintenance tasks.

Overview

Maintaining large Google Drive folders of images often results in inefficient storage and slow load times. This robust n8n workflow solves this by providing a hands-off, scheduled image optimization solution. Utilizing a powerful schedule n8n trigger, the system wakes up daily, identifies images in a designated input folder, and sends them to the Tinify compression API. The n8n workflow manages the entire file lifecycle: downloading the original file via a Google Drive n8n node, uploading the compressed version back to Google Drive, archiving the uncompressed file, and meticulously logging the performance gains (original size vs. compressed size) in an n8n Data Table. Finally, it uses a custom code n8n node to aggregate this data and send a professional, detailed compression report via Gmail. This end-to-end automation ensures efficient cloud storage management and guaranteed file optimization using a sophisticated n8n template.

How it Works

This powerful n8n workflow operates in four main phases:


  1. Trigger and Initialization: The Daily at 08:00 am n8n trigger initiates the process every morning. A unique processingid is generated immediately by the Generate Processing Id n8n node to track all logs related to this specific run.

  2. File Retrieval and Preparation: The Get all files Google Drive n8n node fetches a list of files from the Google Drive input folder. This list is then split into two parallel paths using Loop Over Original Files and Loop Over Processed Files n8n nodes for sequential compression and archiving.

  3. Compression and Logging Loop: The compression path enters a loop for each file: the Load Raw Image Google Drive n8n node downloads the file. The Tiny URL API Call n8n node sends the binary data for compression using the external Tinify API. Once compressed, the workflow fetches the result using Download Compressed Image and saves it via the Save to Remove Background Google Drive n8n node into the designated 'Compressed' folder. Crucially, the Processing Logs n8n node records metrics like original size, compressed size, and the file ID in a structured Data Table. The archiving path simultaneously moves the original file using the Move Files to the Folder /Original Google Drive n8n node.

  4. Reporting: After all compression loops are completed, the Collect Logs n8n node retrieves all data associated with the current processingid. The Generate Report code n8n node compiles this data into a comprehensive HTML report, calculating the total data saved. Finally, the Send Report Gmail n8n node delivers the detailed summary report to the recipient's inbox, showcasing the efficiency of this n8n workflow.

Installation Guide

To deploy this automated n8n workflow, follow these setup steps:


  1. Import the n8n Workflow: Copy the provided JSON into your n8n instance using the 'Import from JSON' feature.

  2. Google Drive Setup: Create three specific folders in Google Drive: Input, Compressed, and Original Images Archive. Update the Folder IDs in the Get all files, Save to Remove Background, and Move Files to the Folder /Original n8n node configurations. Ensure your Google Drive credential is set up correctly in all relevant n8n nodes.

  3. TinyPNG/Tinify API Key: Obtain an API key from Tinify. Create an n8n HTTP Basic Auth credential named "Tinify API Credential". Use api as the Username and your Tinify API key as the Password. Update the Tiny URL API Call n8n node to use this credential.

  4. Data Table Configuration: Create an n8n Data Table (e.g., named “Image Compression”) with the required fields: fileName, originalSize, compressedSize, imageId, outputUrl, and processingId. Update the Data Table ID in both the Processing Logs and Collect Logs n8n nodes.

  5. Email Configuration: Set up your Gmail credential for the Send Report n8n node. Update the recipient email address (currently marked as lYOUREMAIL>) within the Send Report n8n node parameters.

  6. Activation: Activate the n8n workflow to enable the daily scheduled n8n trigger.

Node Details

The complex file management and reporting logic rely on several specialized n8n node components:

Daily at 08:00 am (Schedule Trigger): This critical n8n trigger initiates the compression batch process at a fixed time every day.
Generate Processing Id (Set Node): Ensures every execution of the n8n workflow has a unique identifier for logging purposes.
Get all files (Google Drive Node): Executes the initial query against the target Google Drive folder, providing the data list for the subsequent batch processes.
Tiny URL API Call (HTTP Request Node): Handles the external API interaction, sending the binary image data to the Tinify compression service using configured n8n credentials.
Save to Remove Background (Google Drive Node): This Google Drive n8n node handles the file upload of the newly compressed image to the designated output folder.
Processing Logs (Data Table Node): Records essential metadata (file name, size reduction, IDs) for detailed reporting within n8n.
Move Files to the Folder /Original (Google Drive Node): Archives the original files, maintaining a clean input folder for the next n8n trigger run.
Generate Report (Code Node): A custom scripting n8n node responsible for executing complex calculations (total savings) and generating the final HTML email body.


  • Send Report (Gmail Node): Sends the final, formatted report via email, concluding the automated n8n workflow.

Related n8n Workflows

Free

Nodes: 9 Nodes
Updated: December 26 2025
View all
Created by

Automation, AI and Analytics for Supply Chain & Business Optimization Helping businesses streamline operations using n8n, AI agents, and data science to enhance efficiency and sustainability. Linkedin: www.linkedin.com/in/samir-saci

Featured*