Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active January 3, 2022 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/27740be4bf35d27c47921c5c425fa725 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/27740be4bf35d27c47921c5c425fa725 to your computer and use it in GitHub Desktop.
Convert PowerPoint PPT to JPG in Python
import aspose.slides as slides
import aspose.pydrawing as drawing
# Load presentation
pres = slides.Presentation("presentation.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
# Loop through slides
for index in range(pres.slides.length):
# Get reference of slide
slide = pres.slides[index]
# Save as JPG
slide.get_thumbnail(scaleX, scaleY).save("slide_{i}.jpg".format(i = index), drawing.imaging.ImageFormat.jpeg)
import aspose.slides as slides
import aspose.pydrawing as drawing
# Load presentation
pres = slides.Presentation("presentation.pptx")
# Create a bitmap object
bmp = drawing.Bitmap(1000, 700)
# Set notes and comments position
opts = slides.export.RenderingOptions()
opts.notes_comments_layouting.notes_position = slides.export.NotesPositions.BOTTOM_TRUNCATED
# To include comments
opts.notes_comments_layouting.comments_area_color = drawing.Color.orange
opts.notes_comments_layouting.comments_area_width = 200
opts.notes_comments_layouting.comments_position = slides.export.CommentsPositions.RIGHT
# Loop through slides
for index in range(pres.slides.length):
# Generate graphics from bitmap
graphics = drawing.Graphics.from_image(bmp)
# Render slide to graphics
pres.slides[index].render_to_graphics(opts, graphics)
# Save as JPG
bmp.save("slide_{i}.jpg".format(i = index), drawing.imaging.ImageFormat.jpeg)
import aspose.slides as slides
import aspose.pydrawing as drawing
# Load presentation
pres = slides.Presentation("presentation.pptx")
# Loop through slides
for index in range(pres.slides.length):
# Get reference of slide
slide = pres.slides[index]
# Save as JPG
slide.get_thumbnail().save("slide_{i}.jpg".format(i = index), drawing.imaging.ImageFormat.jpeg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment