n8n

How to Automate Google Drive Image Compression?

Keep your image library lean without manual work. New images dropped into a chosen Google Drive folder are compressed and saved to another folder, ready for web and sharing. Ideal for marketing teams, ecommerce stores, and anyone who handles many images.

The flow is simple and reliable. A Google Drive trigger checks a specific folder every minute for new files. When it finds one, it downloads the image, sends the binary file to TinyPNG using an HTTP request, reads the location from the response, then fetches the optimized file. The final step uploads the smaller image to a selected Google Drive folder and adds the word optimised to the file name. This cuts file sizes and speeds up publishing without anyone touching the files.

Setup takes a few minutes and uses your Google Drive account and a TinyPNG API key. Expect faster page loads, smaller storage use, and a simple pipeline that runs on its own. Great for product photos, blog graphics, and social media assets that need to stay light and fast.

What are the key features?

  • Folder watch in Google Drive that checks every minute for new files
  • Direct image download from Google Drive using the file id
  • Binary upload to TinyPNG via HTTP request for compression
  • Full response handling to read the location header for the optimized file
  • Follow up HTTP GET to fetch the optimized image from TinyPNG
  • Upload of the optimized image to a chosen Google Drive folder with an optimised suffix

What are the benefits?

  • Reduce manual work from five steps to zero per image
  • Cut processing time from about ten minutes to around one minute end to end
  • Connect Google Drive and TinyPNG with no extra tools
  • Handle more images each day without adding staff time
  • Publish lighter images that load faster and help SEO

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Google Drive and TinyPNG. See the Tools Required section above for links to create accounts with these services.
  3. In Google Drive, create an input folder for new images and an output folder where optimized files will be saved.
  4. In n8n, double click any Google Drive node, then on the Credential to connect with dropdown, click Create new credential and follow the on screen instructions to connect your Google account. Give the credential a clear name.
  5. Open the Check GDrive for new images node. Select your Drive credential, choose Specific folder, and pick the input folder. Set the event to file created and confirm it is polling every minute.
  6. Open the Download image node. Use the same Google Drive credential. Confirm operation is Download and the file id is set to the incoming id. The binary property name should be data to match later steps.
  7. Open the Optimise Send image to TinyPNG HTTP Request node. Set Method to POST and URL to https://api.tinify.com/shrink. In Headers, set Authorization to Basic followed by your base64 encoded TinyPNG API key. Make sure Send Binary Data is on and Input Data Field Name is data.
  8. Create your TinyPNG API key in your TinyPNG account. If unsure, open the HTTP node, choose Create new credential if available or keep using the header approach, and follow on screen instructions.
  9. Open the Get optimised image from tinyPNG HTTP Request node. Confirm the URL is set to the location header from the previous response using the expression and that Method is GET.
  10. Open the final Google Drive node. Choose your Drive credential, set operation to Upload, pick the output folder, and set a file name that adds the word optimised to the original name.
  11. Turn on the workflow. Drop a test image into the input folder. Check n8n execution logs and confirm a smaller file appears in the output folder.
  12. If nothing happens, verify the watched folder is correct, confirm the TinyPNG Authorization header value, check that the binary field name is data in both HTTP nodes, and make sure your Google account has access to both folders.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

TinyPNG

Sign up

Free tier: 500 free API compressions / mo; additional: $0.009 per image up to 10,000, then $0.002 per image

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.