How to Extract Images from Google Docs and Google Slides

Imagine you’re working with a lengthy Google Document, or a Google Slides presentation, and you need to extract all the embedded images from the text and save them as individual files.

Extract Images in Google Docs

Extract Individual Images

A simple solution to address this issue is as follows: convert your Google Document or Google Slide into a web page. Here’s how you can do it:

Go to the “File” menu. Select the “Share” submenu and then choose “Publish to Web.” It will generate a public web page that contains all the images from your document or slide. You can simply right-click an image on the page and select the “Save Image” option download it to your local disk.

What we have just discussed is a manual process but we can easily automate this with the help of Google Apps Script.

Extract all Images from a Google Document

Open your Google Document containing the images, go to the Extensions menu and choose Apps Script. Copy-paste the code below and run the saveGoogleDocsImages function to download all images to a specific folder in your Google Drive.

The images are sequentially numbered and the file extension is the same as that of the embedded inline image.

function saveGoogleDocsImages() {
  // Define the folder name where the extracted images will be saved
  const folderName = 'Document Images';

  // Check if a folder with the specified name already exists
  const folders = DriveApp.getFoldersByName(folderName);

  // If the folder exists, use it; otherwise, create a new folder
  const folder = folders.hasNext() ? folders.next() : DriveApp.createFolder(folderName);

  // Get all the images in the document's body and loop through each image
  DocumentApp.getActiveDocument()
    .getBody()
    .getImages()
    .forEach((image, index) => {
      // Get the image data as a Blob
      const blob = image.getBlob();

      // Extract the file extension from the Blob's content type (e.g., 'jpeg', 'png')
      const [, fileExtension] = blob.getContentType().split('/');

      // Generate a unique file name for each image based on its position in the document
      const fileName = `Image #${index + 1}.${fileExtension}`;

      // Set the Blob's name to the generated file name
      blob.setName(fileName);

      // Create a new file in the specified folder with the image data
      folder.createFile(blob);

      // Log a message indicating that the image has been saved
      Logger.log(`Saved ${fileName}`);
    });
}

Extract all Images from Google Slides

The Apps Script code to download images from a Google Slides presentation is similar. The function iterates over the slides in the presentation and then for each slide, the function iterates over the images in that slide.

function extractImagesFromSlides() {
  // Define the folder name where the extracted images will be saved
  const folderName = 'Presentation Images';

  // Check if a folder with the specified name already exists
  const folders = DriveApp.getFoldersByName(folderName);

  // If the folder exists, use it; otherwise, create a new folder
  const folder = folders.hasNext() ? folders.next() : DriveApp.createFolder(folderName);

  // Iterate through each slide in the active presentation
  SlidesApp.getActivePresentation()
    .getSlides()
    .forEach((slide, slideNumber) => {
      // Retrieve all images on the current slide
      slide.getImages().forEach((image, index) => {
        // Get the image data as a Blob
        const blob = image.getBlob();

        // Extract the file extension from the Blob's content type (e.g., 'jpeg', 'png')
        const fileExtension = blob.getContentType().split('/')[1];

        const fileName = `Slide${slideNumber + 1}_Image${index + 1}.${fileExtension}`;

        // Set the Blob's name to the generated file name
        blob.setName(fileName);

        // Create a new file in the specified folder with the image data
        folder.createFile(blob);

        Logger.log(`Saved ${fileName}`);
      });
    });
}

SlideCasts – Sync YouTube Videos with your Google Slides Presentation

Google Slides - YouTube Sync

SlideCasts let you combine YouTube videos and Google Sides / PowerPoint presentations in a single-player. The speaker video and the slides appear side-by-side and, as the video progresses, the slides auto-change in sync with the video.

You can try a live demo of SlideCasts here. Just hit the play button on the YouTube video and you’ll notice that the slides will change at the 10s, 25s and 30s mark (configurable).

SlideCasts can be really useful for educators involved in remote teaching. The teacher’s “talking head” video can be uploaded to YouTube and the lecture slides can be hosted on Google Slides.

If your course slides are available as a PowerPoint presentation that will work as well since you can directly upload your PPT and PPTX files to Google Slides.

How to Sync Presentation Slides with Video

The first step is to install Creator Studio. Next go to slides.google.com and open any existing presentation.

Go to the Addons menu inside Slides, choose Creator Studio and then select Create Slidecasts. Here specify the URL of the YouTube video and your Google Slides deck (both should be public).

Next, specify the timestamps in mm:ss format (minute seconds) when the slides should change in sync with the video.

For instance, if you want the second slide to show at the 15s point in the video, the 3rd slide at the 45s mark and the 4th slide at 1 minute, 20 second mark, your markers would be written as:

0, 15, 45, 1:20

That’s pretty much it. Click the Generate button and copy-paste the HTML code into your website.

The SlideCast player is responsive so the video and slides will auto-resize based on the size of the visitor’s screen.

Download Creator Studio

Embed YouTube SlideCasts