Automatic Google Drive Image Optimization via TinyPNG - n8n Workflow

Streamline your content pipeline with this n8n workflow. Automatically monitor Google Drive for new images, optimize them using TinyPNG, and save the compressed files back to the cloud.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Web developers needing lightweight assets.
Content managers looking to optimize image loading times.
Users seeking to automate cloud storage management tasks.
Anyone interested in using an efficient n8n template for external API integration.

Overview

Managing high-resolution images can quickly consume cloud storage and slow down websites. This specialized n8n workflow addresses this challenge by providing a fully automated image optimization solution. By leveraging the power of the TinyPNG API, this n8n template ensures that every image uploaded to a designated Google Drive folder is instantly compressed without quality loss.

This robust n8n automation eliminates the manual steps of downloading, compressing, and re-uploading files. It utilizes the Google Drive n8n node set for seamless integration, offering an excellent example of how n8n can connect cloud services with external processing tools to create powerful, hands-off processes. Setting up this n8n workflow is straightforward, requiring only Google Drive and TinyPNG credentials.

How it Works

The operation of this n8n workflow begins with a specialized n8n trigger. The process unfolds as follows:


  1. Trigger (n8n Trigger): The Google Drive Trigger n8n node monitors a specific folder for the fileCreated event. When a new image is added, the n8n workflow is activated.

  2. Download: A standard Google Drive n8n node receives the file ID from the trigger payload and downloads the binary image data into the n8n execution context.

  3. Optimize Request: The first HTTP Request n8n node sends the binary image data to the TinyPNG API (https://api.tinify.com/shrink) using a POST method. This step requires the user to configure the Authorization header with their Base64-encoded TinyPNG API key, as detailed in the setup sticky notes.

  4. Retrieve Optimized Image: The TinyPNG API responds with a location header pointing to the optimized image resource. The subsequent HTTP Request n8n node dynamically retrieves this URL ({{ $json.headers.location }}) to download the compressed binary data.

  5. Final Upload: A final Google Drive n8n node takes the optimized image data and uploads it to a predefined output folder in Google Drive. This completes the fully automated image optimization process provided by this n8n template.

Installation Guide

To deploy this n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and paste it into your n8n instance using the 'New' -> 'Import from JSON' option.

  2. Google Drive Credentials: Set up your Google Drive OAuth2 API credentials within n8n. These credentials must be assigned to the 'Check GDrive for new images' n8n trigger and both Google Drive n8n node instances.

  3. Configure Trigger Folder: In the 'Check GDrive for new images' n8n trigger node, select the specific Google Drive folder you wish to monitor for new image uploads.

  4. TinyPNG API Key: Visit the TinyPNG developer portal to obtain an API key.

  5. Configure Optimization Node: In the 'Optimise - Send image to TinyPNG' n8n node, update the 'Authorization' header parameter value. This value must be Basic YOURAPIKEYINBASE_64 (e.g., encoded using tools like base64encode.org).

  6. Configure Output Folder: In the final Google Drive n8n node, select the folder where the optimized images should be saved.

  7. Activate: Save and activate the n8n workflow.

Node Details

This n8n workflow leverages several key n8n node components:

Check GDrive for new images (Google Drive Trigger): This critical n8n trigger initiates the automation. It is configured to watch a specific Google Drive folder for the fileCreated event, ensuring the n8n workflow runs instantly upon upload.
Download image (Google Drive n8n node): Function is set to 'download'. It uses an expression (={{ $json.id }}) to dynamically retrieve the ID of the file that triggered the automation.
Optimise - Send image to TinyPNG (HTTP Request n8n node): This node handles the submission of the image for optimization. Key configuration includes setting the method to POST, content type to binaryData, and securely transmitting the TinyPNG API key via the Basic Authorization header.
Get optimised image from tinyPNG (HTTP Request n8n node): This node uses a dynamic URL derived from the previous node's response headers (={{ $json.headers.location }}) to fetch the newly optimized image data.


  • Google Drive (Google Drive n8n node): The final step of this n8n workflow. It is configured for the 'upload' operation, receiving the optimized binary data and saving it to a designated output folder, often appending '-optimised' to the original filename.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by
Jonathan
Jonathan

Featured*