Convert OTP Slides to PNG Images in Python

Render every slide in an OTP presentation template as a separate PNG image with Aspose.Slides for Python via Java.

Convert OTP to PNG in Python

Aspose.Slides for Python via Java can load an OTP presentation template, render each slide, and save the rendered content as a PNG image. This produces one image per slide and does not require Microsoft PowerPoint, LibreOffice, or OpenOffice.

Convert OTP to PNG using Python

Create a Presentation from the OTP file, access each slide through a variable, call getImage, and save the rendered image with ImageFormat.Png.

Python code for converting OTP slides to PNG

presentation = Presentation("presentation.otp")
try:
    slide_count = presentation.getSlides().size()

    for slide_index in range(slide_count):
        slide = presentation.getSlides().get_Item(slide_index)
        slide_image = slide.getImage(2, 2)
        try:
            file_path = f"slide-{slide_index + 1}.png"
            slide_image.save(file_path, ImageFormat.Png)
        finally:
            slide_image.dispose()
finally:
    presentation.dispose()

How to convert OTP slides to PNG in Python

Follow these steps to render the slides in an OTP presentation template as separate PNG images.

  1. Install Aspose.Slides for Python via Java .

  2. Configure the package and start the Java Virtual Machine in your application.

  3. Open the source OTP file with Presentation and access each slide through a variable.

  4. Call getImage for each slide and save the result with ImageFormat.Png.