Convert PowerPoint PPT to JPG in Python

About PowerPoint to JPG Conversion

With Aspose.Slides .NET API you can convert PowerPoint PPT or PPTX presentation to JPG image in Python. It is also possible to convert PPT/PPTX to BMP, PNG or SVG in Python. With this features it’s easy to implement your own presentation viewer, create  the thumbnail for every slide. This may be useful if you want to protect presentation slides from copywriting, demonstrate presentation in read-only mode. Aspose.Slides allows to convert the whole presentation or a certain slide into image formats. 

todo:image_alt_text

Convert PowerPoint PPT/PPTX to JPG

Here are the steps to convert PPT/PPTX to JPG:

  1. Create an instance of Presentation class.
  2. Get the slide object of ISlide type from Presentation.Slides collection.
  3. Create the thumbnail of each slide and then convert it into JPG. ISlide.GetThumbnail(float scaleX, float scaleY) method is used to get a thumbnail of a slide, it returns Bitmap object as a result. GetThumbnail method has to be called from the needed slide of ISlide type, the scales of the resulting thumbnail are passed into the method.
  4. After you get the slide thumbnail, call [IImage.Save(string filename, ImageFormat format)]((https://reference.aspose.com/slides/python-net/aspose.slides/iimage/) method from the thumbnail object. Pass the resulting file name and the image format into it. 
import aspose.slides as slides

pres = slides.Presentation("pres.pptx")

for sld in pres.slides:
    bmp = sld.get_image(1, 1)
    bmp.save("Slide_{num}.jpg".format(num=str(sld.slide_number)), slides.ImageFormat.JPEG)

Convert PowerPoint PPT/PPTX to JPG with Customized Dimensions

To change the dimension of the resulting thumbnail and JPG image, you can set the ScaleX and ScaleY values by passing them into the ISlide.GetThumbnail(float scaleX, float scaleY) method:

import aspose.slides as slides

pres = slides.Presentation("pres.pptx")

desiredX = 1200
desiredY = 800
scaleX = (float)(1.0 / pres.slide_size.size.width) * desiredX
scaleY = (float)(1.0 / pres.slide_size.size.height) * desiredY

for sld in pres.slides:
    bmp = sld.get_image(scaleX, scaleY)
    bmp.save("Slide_{num}.jpg".format(num=str(sld.slide_number)), slides.ImageFormat.JPEG)

See also

See other options to convert PPT/PPTX into image like: