Convert PPT to JPG in Python

While working with PowerPoint presentations in Python, you may need to generate thumbnails for a PPT. For example, while creating a slideshow or a presentation manipulation application. In this article, you will learn how to convert a PowerPoint PPT to JPG images in Python. We will also cover how to generate JPG images having custom dimensions and render slide notes and comments.

Python PowerPoint to JPG Converter - Free Download

To convert PowerPoint PPT to JPG images, we will utilize Aspose.Slides for Python. It is a powerful library to implement presentation manipulation features in Python. Using the library, you can create, modify and convert the presentations seamlessly. Use the following pip command to install the library from PyPI.

> pip install aspose.slides

INFO: Aspose.Slides provides classes and methods that allow you to convert PPT to PNG and also perform the PNG to PPT and JPG to PPT reverse tasks. Similarly, you can use Aspose.Slides to convert JPG to PPT, convert PNG to PPT, convert HTML to PPT, convert PDF to PPT, etc.

Convert a PPT to JPG in Python

The following are the steps to convert a PPT to JPG images in Python.

  • First, load the presentation file using the Presentation class.
  • Then, iterate through the slides using Pesentation.slides collection.
    • Get reference of each ISlide in the collection using slide’s index.
    • Finally, use ISlide.get_thumbnail().save(string, ImageFormat.jpeg) method to convert a slide to JPG image.

The following code sample shows how to convert a PowerPoint PPTX to JPG in Python.

The following screenshot shows the resultant JPG image of the first slide in the presentation.

Convert PowerPoint PPT to JPG in Python

Resultant JPG Image

Python PPTX to JPG - Customize Image Dimensions

You can also customize the dimensions of the resultant JPG images by providing width and height. Also, you can scale the images as per your requirements. The following steps demonstrate how to convert PPTX to JPG with customized dimensions and scaling.

  • First, load the presentation file using the Presentation class.
  • Create two variables to set the width and height of JPG images.
  • Set X and Y scaling of the images using the specified width and height.
  • Iterate through the slides using Pesentation.slides collection.
    • Get reference of each ISlide from the collection using slide’s index.
    • Convert slide to JPG using ISlide.get_thumbnail(scaleX, scaleY).save(string, ImageFormat.jpeg) method.

The following code sample shows how to convert PPTX to JPG with customized scaling and dimensions in Python.

PPTX to JPG in Python - Include Notes and Comments

MS PowerPoint also allows you to write comments and notes for each slide in the presentation. By default, the comments and notes are not rendered in PPT to JPG conversion. However, you can include them in the resultant JPG images following the below steps.

  • First, load the presentation file using the Presentation class.

  • Create a Bitmap object by specifying the width and height of the resultant images.

  • Create an object of RenderingOptions class.

  • Specify position for notes using RenderingOptions.notes_comments_layouting.notes_position property.

  • To include comments, use RenderingOptions.notes_comments_layouting.comments_position property.

  • Iterate through the slides in Pesentation.slides collection.

    • Generate graphics object from Bitmap using Graphics.from_image(Bitmap) method.

    • Render the slide to graphics using Presentation.slides[index].render_to_graphics(RenderingOptions, graphics) method.

    • Save slide as JPG using Bitmap.save(string, ImageFormat.jpeg) method.

The following code sample shows how to render notes and comments in PPT to JPG conversion in Python.

The following screenshot shows the resultant JPG image that contains slide notes and comments.

Convert a PPT to JPG with Comments and Notes in Python

PPT to JPG with Slide Notes and Comments

PowerPoint PPT to JPG Python Converter - Get a Free License

You can use Aspose.Slides for Python without evaluation limitations by getting a temporary license.

Conclusion

In this article, you have learned how to convert PowerPoint PPT or PPTX to JPG images in Python. In addition, you have seen how to generate JPG images with custom dimensions and scaling. We have also covered how to include slide notes and comments in PPT to JPG conversion.

Python PowerPoint to JPG Converter - Read More

Aspose.Slides for Python also provides a wide range of features that you can explore using the documentation. In case you would have any questions, contact us on our forum.

See Also

Tip: You may want to check out Aspose FREE PowerPoint to JPG converter.