Convert Google Slides Presentation to Image Sequence

The Creator Studio add-on for Google Slides can export your Google Slides presentation to a variety of formats including animated GIF images, MP4 video and a sequence of images in PNG format.

Internally, the Slides add-on uses the Google API for Node.js to generate the PNG thumbnails of the presentation and then downloads them using the native Fetch API of the browser.

/* global gapi */

const SIZE = {
  UNSPECIFIED: 'THUMBNAIL_SIZE_UNSPECIFIED',
  LARGE: 'LARGE',
  MEDIUM: 'MEDIUM',
  SMALL: 'SMALL',
};

const IMAGE_SIZE = SIZE.SMALL;
const MAX_SLIDE_COUNT = 3;

const getSlideObjects = (presentationId) => {
  return new Promise((resolve, reject) => {
    gapi.client.slides.presentations
      .get({
        presentationId,
        fields: 'slides/objectId',
      })
      .then(({ result }) => {
        const pageObjects = result.slides.map(({ objectId }) => objectId);
        resolve(pageObjects.slice(0, MAX_SLIDE_COUNT));
      })
      .catch((err) => reject(err));
  });
};

const getThumbnailUrl = (presentationId, pageObjectId) => {
  return new Promise((resolve, reject) => {
    gapi.client.slides.presentations.pages
      .getThumbnail({
        presentationId,
        pageObjectId,
        'thumbnailProperties.mimeType': 'PNG',
        'thumbnailProperties.thumbnailSize': IMAGE_SIZE,
      })
      .then(({ result }) => {
        resolve(result.contentUrl);
      })
      .catch((err) => {
        reject(err);
      });
  });
};

const getImageLinks = (presentationId) => {
  return new Promise((resolve, reject) => {
    getSlideObjects(presentationId)
      .then((pageObjects) => {
        return pageObjects.map((pageObjectId) => {
          return getThumbnailUrl(presentationId, pageObjectId);
        });
      })
      .then((thumbnailUrls) => {
        return Promise.all(thumbnailUrls);
      })
      .then((fileUrls) => resolve(fileUrls.filter((url) => url)))
      .catch((err) => reject(err));
  });
};

export default getImageLinks;

The presentations.pages.getThumbnail method generates a PNG thumbnail image of the specified slide in the Google Presentation and returns a public URL of the thumbnail image.

Please note that getThumbnail is an ‘expensive’ operation and your Google project can only make 100 requests per 100 seconds per user. It is therefore a good idea to cache the results in localStore to avoid hitting the rate limits.

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.