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.
Convert PowerPoint PPT/PPTX to JPG
Here are the steps to convert PPT/PPTX to JPG:
- Create an instance of Presentation class.
- Get the slide object of ISlide type from Presentation.Slides collection.
- Create the thumbnail of each slide and then convert it into JPG. ISlide.GetImage(float scaleX, float scaleY) method is used to get a thumbnail of a slide, it returns IImage object as a result. GetImage method has to be called from the needed slide of ISlide type, the scales of the resulting thumbnail are passed into the method.
- 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:
with sld.get_image(1, 1) as bmp:
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.GetImage(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:
with sld.get_image(scaleX, scaleY) as bmp:
bmp.save("Slide_{num}.jpg".format(num=str(sld.slide_number)), slides.ImageFormat.JPEG)
Tip
Aspose provides a FREE Collage web app. Using this online service, you can merge JPG to JPG or PNG to PNG images, create photo grids, and so on.
Using the same principles described in this article, you can convert images from one format to another. For more information, see these pages: convert image to JPG; convert JPG to image; convert JPG to PNG, convert PNG to JPG; convert PNG to SVG, convert SVG to PNG.
See also
See other options to convert PPT/PPTX into image like: