Created
September 5, 2025 12:59
-
-
Save sterlingsky/156296385631d28cae8ba1d61eb5cb7d to your computer and use it in GitHub Desktop.
Position all slide Images to take up full slide
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Instructions