Google Docs And Google Slides Image Extraction: Learn Step By Step

Google Docs And Google Slides Image Extraction: Learn Step By Step

This beginner-friendly article will show you how to easily extract photos from Google Docs and Google Slides. To master the skill of picture extraction, adhere to our detailed guidelines.

Have you have a lengthy Google Document or Google Slides presentation that you need to remove embedded photos from? Do not worry; we have a quick and easy solution that can help you save time and work. This post will demonstrate how to manually or automatically extract specific photos from your papers and presentations using Google Apps Script.

Google Docs And Google Slides Image Extraction: Learn Step By Step

Extract Individual Images:

Follow these procedures to manually remove photographs from your Google Document or Google Slides presentation and save them as separate files:

  • Select “File” from the menu.
  • A “Share” submenu should be chosen.
  • selecting “Publish to Web.”

A public web page containing all the photographs from your presentation or document will be created as a result of your operation. Simply choose “Save Image” from the menu when you right-click on a picture on the page to save it to your computer’s hard drive.

Extract all Images from a Google Document:

Google Apps Script might be your greatest friend if you’re working with several photos or want to automate the process. To extract every image from a Google Document or Google Slides presentation, follow these steps:

For Google Docs:

  • Access the photos’ Google Document by opening it.
  • Select “Extensions” from the menu.
  • Decide on “Apps Script.”
  • The following code should be copied and pasted into the script editor:
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}`);
    });
}

Run the saveGoogleDocsImages function after saving the script. A specific folder in your Google Drive will be where all of the photographs are downloaded. With the same file extension as the embedded picture, each image will be numbered consecutively.

Extract all Images from Google Slides:

Similar steps apply for Google Slides:

  • Go to the Google Slides presentation where the photographs are located.
  • Select “Extensions” from the menu.
  • Decide on “Apps Script.”
  • The following code should be copied and pasted into the script editor:
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}`);
      });
    });
}

Run the extractImagesFromSlides method after saving the script. Each image’s filename will include the slide and location, and all of the photographs will be downloaded to a specific folder in your Google Drive.

Knowing how to extract photos from Google Docs and Google Slides can help you manage your visual information more effectively and optimize your workflow. This article gives you the tools to maximize your papers and presentations whether you decide to use the manual approach or Google Apps Script automation.

Congratulations! You have mastered the art of extracting images from Google Docs and Google Slides. You now have a useful ability available, whether you decide to use the manual technique or the automated approach using Google Apps Script.

Use image extraction to your advantage right now to see an increase in your productivity and creativity. Cheers to extraction!

We have solved the puzzles of picture extraction from Google Docs and Google Slides in this beginner’s guide. You now have the knowledge and abilities to extract photos like a pro, from manual extraction to utilizing the power of Google Apps Script. Say good-bye to image-related annoyances and hello to a workflow that is more effective!

Leave a Comment