Introduction
In today’s visual‑first environment, presenting ideas as crisp, high‑resolution images can be a game‑changer. Whether you need static assets for a website, social media, or an offline brochure, converting Google Slides decks into PNG files is a handy skill. Google Apps Script offers two powerful pathways to achieve this: the native Google Slides API, which gives fine‑grained control over slide rendering, and the Google Drive API, which treats each slide as a downloadable export. This article walks you through the entire process—from setting up a script project, authenticating the appropriate services, to writing concise functions that output PNGs at the desired resolution. By the end, you’ll know which API best matches your requirements and how to implement it efficiently.
Understanding the Two APIs
The Google Slides API works directly with the presentation object model. It lets you request a specific slide, define export dimensions, and retrieve a binary PNG stream. This approach is ideal when you need per‑slide customization, such as applying different image sizes or extracting only selected slides. Conversely, the Google Drive API treats the entire presentation as a file that can be exported in various formats, including PNG. By using the files.export endpoint, you can download every slide in one request, which simplifies bulk conversions but offers less granular control. Understanding these differences helps you decide whether precision or simplicity is your priority.
Setting Up the Apps Script Project
1. Open Google Apps Script via script.google.com and create a new project.
2. Enable the required services: Google Slides API and Google Drive API (Resources → Advanced Google services).
3. Add the following scopes to the manifest (appsscript.json) so the script can read presentations and write images to Drive:
https://www.googleapis.com/auth/presentations.readonlyhttps://www.googleapis.com/auth/drive.file
4. Save the project and run a simple test function to trigger the authorization flow. Once authorized, the script can interact with both APIs securely.
Converting Slides with the Google Slides API
The Slides API provides the presentations.pages.getThumbnail method, which returns a PNG URL at a specified size. Below is a concise function that loops through each slide, fetches the thumbnail, and stores it in a designated Drive folder:
- Retrieve the presentation ID and target folder ID.
- Call
Slides.Presentations.Pages.getThumbnailfor each page ID, passing{thumbnailProperties: {mimeType: 'PNG', widthPixels: 1920, heightPixels: 1080}}. - Fetch the image via
UrlFetchApp.fetch(url).getBlob()and rename itSlide-1.png,Slide-2.png, etc. - Save the blob to Drive with
DriveApp.getFolderById(folderId).createFile(blob).
This method excels when you need consistent dimensions or when you want to skip non‑visual slides (e.g., hidden notes).
Converting Slides with the Google Drive API
If you prefer a bulk export, the Drive API’s files.export endpoint can produce a ZIP of PNGs for the entire deck. The steps are:
- Construct the export URL:
https://www.googleapis.com/drive/v3/files/FILE_ID/export?mimeType=image/png. - Use
UrlFetchApp.fetchwith the proper OAuth token (automatically handled by Apps Script) to download the binary data. - The response contains a multi‑part payload where each part corresponds to a slide image; you can split it using the boundary string from the
Content-Typeheader. - Iterate over the parts, create blobs, and save each as
Slide‑01.png,Slide‑02.png, etc., into your chosen Drive folder.
While this approach requires a bit more parsing, it reduces the number of API calls and is faster for large presentations.
Best Practices and Choosing the Right Method
• Performance: For presentations with fewer than 20 slides, the Slides API’s per‑slide calls are negligible. For larger decks, the Drive API’s single export minimizes latency.
• Resolution Control: Slides API lets you define exact pixel dimensions; Drive API respects the default export size, which may need post‑processing if you require specific DPI.
• Error Handling: Wrap API calls in try…catch blocks, log failed slide IDs, and implement exponential back‑off for quota‑limit retries.
• File Organization: Create a dedicated folder per conversion run, and optionally add a timestamp to the folder name for easy tracking.
By aligning these practices with your project’s needs, you ensure reliable, high‑quality PNG outputs without unnecessary complexity.
Conclusion
Converting Google Slides to PNG images via Apps Script is both practical and versatile, thanks to the complementary strengths of the Slides and Drive APIs. The Slides API offers precise control over image dimensions and selective export, making it perfect for custom workflows. In contrast, the Drive API provides a streamlined bulk export, ideal for large decks where speed outweighs fine‑tuned settings. Setting up the script environment, handling authentication, and implementing robust error handling are essential steps regardless of the chosen path. By following the best‑practice guidelines outlined above, you can automate high‑resolution image generation that integrates seamlessly with your existing Google Workspace processes, empowering you to reuse slide content across any platform.









