Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save Slide as Image #963

Open
shllgtca opened this issue Apr 3, 2024 · 2 comments
Open

Save Slide as Image #963

shllgtca opened this issue Apr 3, 2024 · 2 comments

Comments

@shllgtca
Copy link

shllgtca commented Apr 3, 2024

Hi All!

This library is a great contribution for the community, tks for that!

Is there a way how to save a slide as an image?

kind regards!

@MartinPacker
Copy link

An easy one to answer - but not the answer you want: python-pptx doesn't render the slides so can't do this. You'd have to automate a screen grab - on whichever platform you're on.

@scanny
Copy link
Owner

scanny commented Apr 3, 2024

@shllgtca I believe you can do this with LibreOffice. It's not pretty; the LibreOffice application needs to be installed and it actually loads as though you were using it to do the save operation by hand, but it does work. Takes a fair amount of time. Probably not a problem for onesy-twosies on your own machine but can be problematic if you're running it in production in the cloud or whatever.

I can't say I've tried it for this exact purpose; I've used it for DOC -> DOCX conversions and actually used it in a production system running in the cloud on Linux. But like I say, it's ugly and slow. Much better than not being able to do it though :)

Installing LibreOffice makes the soffice (command-line) command available. I believe you'll have to convert the PPTX to PDF and then use Ghostscript or something for PDF -> PNG or whatever. This SO question has more, others on search I expect:
https://stackoverflow.com/questions/21523267/how-to-convert-pptx-files-to-jpg-or-png-for-each-slide-on-linux

So this process actually has nothing to do with python-pptx specifically, it works the same no matter how the PPTX got produced. And what you're running is essentially a command-line script, from within Python if you want or using a shell script or whatever suits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants