Skip to content

Instantly share code, notes, and snippets.

@sterlingsky
Created September 5, 2025 12:59
Show Gist options
  • Select an option

  • Save sterlingsky/156296385631d28cae8ba1d61eb5cb7d to your computer and use it in GitHub Desktop.

Select an option

Save sterlingsky/156296385631d28cae8ba1d61eb5cb7d to your computer and use it in GitHub Desktop.
Position all slide Images to take up full slide
function positionImagesFullCover() {
// Get the active presentation
const presentation = SlidesApp.getActivePresentation();
// Get all slides in the presentation
const slides = presentation.getSlides();
// Get the page dimensions (standard slide size)
const pageWidth = presentation.getPageWidth();
const pageHeight = presentation.getPageHeight();
console.log(`Processing ${slides.length} slides`);
console.log(`Slide dimensions: ${pageWidth} x ${pageHeight} points`);
// Loop through each slide
slides.forEach((slide, index) => {
console.log(`Processing slide ${index + 1}`);
// Get all images on the current slide
const images = slide.getImages();
if (images.length === 0) {
console.log(`No images found on slide ${index + 1}`);
return; // Skip to next slide if no images
}
// Process each image on the slide
images.forEach((image, imageIndex) => {
try {
// Position the image at 0,0 (top-left corner)
image.setLeft(0);
image.setTop(0);
// Make the image cover the entire slide
image.setWidth(pageWidth);
image.setHeight(pageHeight);
console.log(`Positioned image ${imageIndex + 1} on slide ${index + 1}`);
} catch (error) {
console.error(`Error processing image ${imageIndex + 1} on slide ${index + 1}:`, error.message);
}
});
});
console.log('Finished processing all slides');
}
@sterlingsky
Copy link
Author

Instructions

  1. Open new google slides deck
  2. Import images into all SLides
  3. Hit Extensions > Apps Script
  4. Delete the placeholder function from the editor
  5. Paste the Above script into the editor
  6. Hit save. You should then see PositionImagesFullCover as a function name at top of editor
  7. Hit Run. This will position all your images perfectly to scale to fill the full slides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment