Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Created November 24, 2021 05:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanaikech/66a83c01e1f99829a85f909f8facb834 to your computer and use it in GitHub Desktop.
Save tanaikech/66a83c01e1f99829a85f909f8facb834 to your computer and use it in GitHub Desktop.
Exporting All Thumbnail Images Retrieved from Google Slides as Zip File using Google Apps Script

Exporting All Thumbnail Images Retrieved from Google Slides as Zip File using Google Apps Script

This is a sample script for exporting all thumbnail images retrieved from Google Slides as a zip file using Google Apps Script.

Sample script

Before you use this script, please enable Slides API at Advanced Google services. Ref

function myFunction() {
  const presentationId = "###"; // Please set Google Slides ID.
  const folderId = "###"; // Please set the folder ID.
  const outputFilename = "###"; // Please set the output filename.

  const blobs = SlidesApp.openById(presentationId)
    .getSlides()
    .map((e, i) =>
      UrlFetchApp.fetch(
        Slides.Presentations.Pages.getThumbnail(
          presentationId,
          e.getObjectId(),
          {
            "thumbnailProperties.mimeType": "PNG",
            "thumbnailProperties.thumbnailSize": "LARGE",
          }
        ).contentUrl
      )
        .getBlob()
        .setName(`page${("000" + (i + 1)).slice(-3)}.png`)
    );
  DriveApp.getFolderById(folderId).createFile(
    Utilities.zip(blobs).setName(outputFilename + ".zip")
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment