Convert Image to PPTX in Python

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

Convert Image to PPTX 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.PPTX.

The resulting PPTX 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 PPTX Using Python

Create a Presentation, add the source image to its first Slide, and save the result in the PowerPoint Open XML format.

Python code for converting an image to PPTX

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.pptx", slides.export.SaveFormat.PPTX)

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

Follow these steps to convert an image to PPTX 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.PPTX.

Convert Images to Other Supported Formats

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