This short guide describes how to edit image in PowerPoint using Python. It covers setting up the IDE, the steps to follow, and sample code for image editing in PowerPoint using Python. You will also learn about various features you can use to enhance the output PPT/PPTX by further editing its images.
Steps to Edit Photo in PowerPoint using Python
- Set up the environment to use Aspose.Slides for Python via .NET to edit a picture
- Load the license and the source presentation file having pictures in it
- Get normal and group pictures from the first slide
- Replace the picture with a new picture from the disk
- Change the position and size of the picture, flip it and rotate it slightly, if required
- Trim the picture from its left and right sides
- Change the color to black and white, increase brightness, and set contrast
- Set its border and shadow, set the description and lock its proportions to avoid resizing
- Save the output file as PPT or PPTX
These steps describe the process to edit a picture in PowerPoint using Python. Load the product license, load the target presentation into memory, access the first slide, get the slide’s normal and group image collections, replace the first image with a new image from disk, and change its properties. You can update the image position and size, flip it, rotate it slightly, set greyscale, brightness, and contrast, and change the border and shadow.
Code for Picture Editing in PowerPoint using Python
This code demonstrates how to change a picture in PowerPoint using Python. You can calculate the frame height from the new image dimensions so the predefined frame doesn’t stretch it. Always clear any existing effects from the picture so new ones don’t stack on top of them.
This article guides you on editing images in a presentation. To compress the presentations, refer to the article Compress PowerPoint Presentation Size using Python.