Google Slides is a popular presentation tool that allows users to create and edit presentations online, and collaborate with others in real-time. However, the platform may not always have all the customization options that users may require, such as setting an image as a background. Fortunately, Google Apps Script provides a solution to this limitation. In this tutorial, we’ll show you how to make a picture a background in Google Slides with Google Apps Script.
Step 1: Create a new Google Slides presentation
The first step is to create a new Google Slides presentation where we can use Google Apps Script to set the image as the background. To do this, create a new Google Slides presentation by going to Google Drive and selecting the “New” button, then select “Google Slides” from the drop-down menu.
Step 2: Open the script editor in Google Slides
Once you have created the presentation, open the script editor by clicking on “Tools” in the menu bar, then selecting “Script editor” from the drop-down menu. This will open a new tab in the browser window with the Google Apps Script editor.
Step 3: Write the script to set the image as background
In the script editor, paste the following code snippet:
function setSlideBackground() {
var slide = SlidesApp.getActivePresentation().getSlides()[0];
var backgroundImage = UrlFetchApp.fetch('').getBlob();
slide.getBackground().setPicture(backgroundImage);
}
The above code retrieves the first slide in the active presentation and sets the image from the URL provided as the background image. Replace the “ with the actual URL of your image.
Step 4: Save the script and run it
After entering the code, save the script by clicking on “File” in the menu bar, then select “Save” to save the script. Once you have saved your script, run it by selecting “Run” in the menu bar, then select “setSlideBackground” from the drop-down menu. The script will run and set the image as the background of the first slide in the active presentation.
Step 5: Confirm the slide background has been set
Go back to the presentation tab in your browser window and confirm that the background of the first slide has indeed been set to the image you provided in the script. If it hasn’t worked, go back to the script editor and make sure that you have entered the correct image URL and that the script has been saved and run.