Convert Image to PPT in Python

Create a PowerPoint 97-2003 presentation from an image with a cross-platform Python API

Convert Image to PPT in Python

Aspose.Slides for Python via .NET lets you create a PowerPoint presentation from a raster image. Add the image to Presentation.images, place it on a slide with ShapeCollection.add_picture_frame, and call Presentation.save with SaveFormat.PPT.

The resulting PPT file contains one slide whose size matches the source image. This workflow preserves the image’s aspect ratio and does not require Microsoft PowerPoint or another presentation application.

Convert an Image to PPT Using Python

Create a Presentation, add the source image to its first Slide, and save the result in the PowerPoint 97-2003 format.

Python code for converting an image to PPT

with slides.Presentation() as presentation:
    slide = presentation.slides[0]

    with slides.Images.from_file("image.png") as source_image:
        presentation_image = presentation.images.add_image(source_image)

    presentation.slide_size.set_size(
        presentation_image.width,
        presentation_image.height,
        slides.SlideSizeScaleType.DO_NOT_SCALE,
    )

    slide.shapes.add_picture_frame(
        slides.ShapeType.RECTANGLE,
        0,
        0,
        presentation_image.width,
        presentation_image.height,
        presentation_image,
    )
    presentation.save("image.ppt", slides.export.SaveFormat.PPT)

How to Convert an Image to PPT Using the Aspose.Slides Python API

Follow these steps to convert an image to PPT in Python.

  1. Install Aspose.Slides for Python via .NET .

  2. Create a Presentation and access its first Slide.

  3. Load the source image with Images.from_file, add it to Presentation.images, and use its dimensions for the slide and picture frame.

  4. Call Presentation.save with the output file path and SaveFormat.PPT.

Convert Images to Other Supported Formats

You can also convert images and save them in other supported formats.