Python: Convert PowerPoint to Images (PNG, JPG, BMP, SVG)

Images are universally compatible and can be easily shared across various platforms, devices, and applications. By converting PowerPoint slides to images, you can distribute your content effortlessly via email, messaging apps, websites, or social media platforms. This makes your presentation accessible to a wider audience and ensures that it can be viewed by anyone, regardless of the software or device they are using. In this article, we will explain how to convert PowerPoint to images in Python using Spire.Presentation for Python.

Install Spire.Presentation for Python

This scenario requires Spire.Presentation for Python and plum-dispatch v1.7.4. They can be easily installed in your Windows through the following pip command.

pip install Spire.Presentation

If you are unsure how to install, please refer to this tutorial: How to Install Spire.Presentation for Python on Windows

Convert PowerPoint Presentation to JPG, PNG or BMP Images in Python

Spire.Presentation for Python offers the ISlide.SaveAsImage() method which enables you to convert the slides in a PowerPoint presentation to image files in formats like PNG, JPG or BMP with ease. The detailed steps are as follows:

  • Create a Presentation object.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Loop through the slides in the presentation.
  • Save each slide to an image stream using ISlide.SaveAsImage() method.
  • Save the image stream to a JPG, PNG or BMP file using Stream.Save() method.
  • Python
from spire.presentation.common import *
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()

# Load a PowerPoint presentation
presentation.LoadFromFile("Sample.pptx")

# Loop through the slides in the presentation
for i, slide in enumerate(presentation.Slides):
    # Specify the output file name
    fileName ="Output/ToImage_ + str(i) + ".png"
    # Save each slide as a PNG image
    image = slide.SaveAsImage()
    image.Save(fileName)
    image.Dispose()

presentation.Dispose()

Python: Convert PowerPoint to Images (PNG, JPG, BMP, SVG)

Convert PowerPoint Presentation to JPG, PNG or BMP Images with a Specific Size in Python

You can convert the slides in a PowerPoint presentation to images with a specific size using ISlide.SaveAsImageByWH() method. The detailed steps are as follows:

  • Create a Presentation object.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Loop through the slides in the presentation.
  • Save each slide to an image stream using ISlide.SaveAsImageByWH() method.
  • Save the image stream to a JPG, PNG or BMP file using Stream.Save() method.
  • Python
from spire.presentation.common import *
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()

# Load a PowerPoint presentation
presentation.LoadFromFile("Sample.pptx")

# Loop through the slides in the presentation
for i, slide in enumerate(presentation.Slides):
    # Specify the output file name
    fileName ="Output/ToImage_" + str(i) + ".png"
    # Save each slide to a PNG image with a size of 700 * 400 pixels
    image = slide.SaveAsImageByWH(700, 400)
    image.Save(fileName)
    image.Dispose()

presentation.Dispose()

Python: Convert PowerPoint to Images (PNG, JPG, BMP, SVG)

Convert PowerPoint Presentation to SVG Images in Python

To convert the slides in a PowerPoint presentation to SVG images, you can use the ISlide.SaveToSVG() method. The detailed steps are as follows:

  • Create a Presentation object.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Enable the Presentation.IsNoteRetained property to retain notes when converting the presentation to SVG files.
  • Loop through the slides in the presentation.
  • Save each slide to an SVG stream using ISlide.SaveToSVG() method.
  • Save the SVG stream to an SVG file using Stream.Save() method.
  • Python
from spire.presentation.common import *
from spire.presentation import *

# Create a Presentation object
presentation = Presentation()

# Load a PowerPoint presentation
presentation.LoadFromFile("Sample.pptx")

# Enable the IsNoteRetained property to retain notes when converting the presentation to SVG files
presentation.IsNoteRetained = True

# Loop through the slides in the presentation
for i, slide in enumerate(presentation.Slides):
    # Specify the output file name
    fileName = "SVG/ToSVG_" + str(i) + ".svg"
    # Save each slide to an SVG image
    svgStream = slide.SaveToSVG()
    svgStream.Save(fileName)

presentation.Dispose()

Python: Convert PowerPoint to Images (PNG, JPG, BMP, SVG)

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.