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 is a web geek, solo entrepreneur and loves making things on the Internet. Google recently awarded him the Google Developer Expert and Google Cloud Champion title for his work on Google Workspace and Google Apps Script.

Awards & Recognition

Google Developer Expert

Google Developer Expert

Google awarded us the Developer Expert title recogizing our work in Workspace

ProductHunt Golden Kitty

ProductHunt Golden Kitty

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

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional title for 5 years in a row

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator award for technical expertise

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

We will never send any spam emails. Promise 🫶🏻