// Slides · Drive · Apps Script

Export each slide as a PNG in Google Slides.

SlidesApp has no built-in image export. Use the Advanced Slides Service (Slides.Presentations.Pages.getThumbnail) to fetch a per-page PNG blob immediately — the contentUrl expires in ~30 minutes, so UrlFetchApp it in the same execution.

I want to save every slide in my Google Slides deck as a PNG file in Drive, without downloading the deck manually.

The script

copy · paste · trigger
exportSlidesAsPng.gs
Apps Script
// Exports every slide as a PNG into a Drive folder named after the deck.
// Requires: Extensions > Apps Script > Services > Slides API (v1) enabled.
function exportSlidesAsPng() {
  var pres = SlidesApp.getActivePresentation();
  var presId = pres.getId();
  var folderName = pres.getName() + ' - PNG exports';
  var folder = DriveApp.createFolder(folderName);
  var slides = pres.getSlides();

  for (var i = 0; i < slides.length; i++) {
    var pageId = slides[i].getObjectId();
    var thumb = Slides.Presentations.Pages.getThumbnail(
      presId,
      pageId,
      { 'thumbnailProperties.thumbnailSize': 'LARGE' }
    );
    var blob = UrlFetchApp.fetch(thumb.contentUrl).getBlob();
    blob.setName('slide-' + (i + 1) + '.png');
    folder.createFile(blob);
  }

  Logger.log('Exported ' + slides.length + ' slides to: ' + folder.getUrl());
}

Need a variant? Gnaw writes a custom version from one sentence — fields, triggers, edge cases handled.

Walkthrough

Why SlidesApp alone won't get you there

SlidesApp, the standard Apps Script service, gives you full read-write access to slide content — shapes, text, speaker notes, layouts — but it has no method that produces an image. There is no getAsPng(), no export(), nothing. The first time I hit this, I spent twenty minutes grepping the autocomplete before accepting the gap is real.

The escape hatch is the Advanced Slides Service, which wraps the Google Slides REST API v1. You enable it under Extensions > Apps Script > Services > Slides API. Once it's on, the global Slides object appears in your script, and Slides.Presentations.Pages.getThumbnail(presentationId, pageObjectId, options) returns a ThumbnailImage resource containing a contentUrl pointing at a PNG.

Fetch the blob immediately — the URL is short-lived

The contentUrl in the thumbnail response is a signed Google URL that expires in approximately 30 minutes. If you store the URL and try to fetch it in a second execution, or even just pause too long in a large deck, you will get a 403 or a redirect to an error page rather than image data. The fix is straightforward: call UrlFetchApp.fetch(thumb.contentUrl).getBlob() in the same loop iteration, then pass that blob directly to folder.createFile().

The thumbnailSize option accepts THREE values: SMALL (240px wide), MEDIUM (800px wide), and LARGE (1600px wide). LARGE is what you almost always want for anything meant to be readable. The height is computed automatically from your deck's aspect ratio — a 16:9 deck at LARGE comes out 1600x900.

One practical note on execution time: a 30-slide deck at LARGE takes roughly 45-60 seconds. Apps Script's default execution limit is 6 minutes (360 seconds), so decks up to around 200 slides are fine in a single run. Past that, you would need to checkpoint slide index to a Script Property and resume.

Running it and finding the output

Open your presentation, go to Extensions > Apps Script, paste the function, and click Run. The first run will trigger an OAuth consent screen asking for Drive and Slides API access — both are required. After you authorize, re-run; the script creates a folder next to your deck in Drive (same parent directory as the presentation file) named 'Your Deck Title - PNG exports' and drops slide-1.png through slide-N.png into it.

The folder URL is logged to the Execution Log (View > Logs) so you can click straight to it. If you want the folder created inside a specific Drive folder rather than root, replace DriveApp.createFolder(folderName) with DriveApp.getFolderById('YOUR_FOLDER_ID').createFolder(folderName).

Want a custom version?

Describe your sheet and the rule you want. Gnaw writes the Apps Script — fields, triggers, edge cases — in one shot.

FAQ

4 questions
I get 'Slides is not defined' when I run the script. What's wrong?
The Advanced Slides Service isn't enabled. In the Apps Script editor, click the + next to Services in the left sidebar, find 'Google Slides API', and click Add. The Slides global only exists after you do this — it's not included in the default Apps Script runtime.
Can I export as JPEG instead of PNG?
No. The Slides.Presentations.Pages.getThumbnail endpoint only returns PNG. If you need JPEG, you can convert the blob using ImgApp (a community library) or accept PNG and rename the extension — but the file content will still be PNG encoded.
The exported images look blurry. How do I get higher resolution?
Use thumbnailSize: 'LARGE', which gives you 1600px on the long edge. That is the maximum the API offers. There is no way to request an arbitrary pixel dimension or a resolution above LARGE through this endpoint.
I only want to export specific slides, not the whole deck. How?
Replace the loop over pres.getSlides() with a hardcoded array of zero-based indexes. For example, to export slides 1 and 3: var indexes = [0, 2]; then iterate over those, using pres.getSlides()[indexes[i]].getObjectId() to get each page ID.