Programmatically extracting slides as images from a PowerPoint presentation (.PPT) [closed]
Asked Answered
H

6

24

Given a PowerPoint presentation in .ppt format, what is the best way to programmatically and using only open source software extract an image representation (in say .jpg or .png) of each slide in the presentation?

The application will run in a Linux server environment, so installing Microsoft Office or Keynote is not an option.

The functionality that I want to achieve programmatically is similar to:

  • Keynote's export functionality (File > Export... > Pictures > JPEG)
  • PowerPoint's Save As JPEG functionality (Save As > Other Formats > JPEG)
Hopkins answered 28/9, 2010 at 15:21 Comment(0)
C
24

You should probably give unoconv a try. According to the man page, "unoconv is a command line utility that can convert any file format that OpenOffice can import, to any file format that OpenOffice is capable of exporting. "

So, to convert ppt to, say, png, you do:

unoconv -f png some-slides.ppt

Should that failed, you may try JODConverter or PyODConverter from Art of Solving. For example, you can use JODConverter from command line:

java -jar lib/jodconverter-cli-2.2.0.jar document.ppt document.png
Council answered 1/10, 2010 at 14:45 Comment(3)
I think it could be the best solution. But you should be aware it depends on open office. Fortunately there is OO headless so you don't have to mess with xvfb.Flareup
I have try jodconverter but its its giving noclassdeffound errorStavro
@MuhammadMuazzam Did you use the latest JODConverter? It seems the latest source/download is kept here: github.com/sbraconnier/jodconverterCouncil
C
3

Given your requirement to run on Linux, it's probably easiest to automate OpenOffice.org.

Exporting as HTML will give you a JPEG or PNG image with configurable quality for each slide.

Claudine answered 28/9, 2010 at 15:24 Comment(0)
A
2

If using a web API is an option I would try google docs API. You can upload a ppt document and then download it back in any of the supported formats including pdf and png.

Agar answered 8/10, 2010 at 9:18 Comment(0)
W
2

Apache POI is a Java library, but has a command-line utility for converting a PPTX files to PNG files.

To run it, invoke this command inside the root of the library's binary download folder:

java -cp "poi-3.10-FINAL-20140208.jar;poi-ooxml-3.10-FINAL-20140208.jar;poi-ooxml-schemas-3.10-FINAL-20140208.jar;ooxml-lib\dom4j-1.6.1.jar;ooxml-lib\stax-api-1.0.1.jar;ooxml-lib\xmlbeans-2.3.0.jar;lib\commons-codec-1.5.jar;lib\commons-logging-1.1.jar;lib\log4j-1.2.13.jar" org.apache.poi.xslf.util.PPTX2PNG presentation.pptx

It's not 100% perfect--I noticed that it doesn't like WordArt or images that have been cropped from within PowerPoint.

Wernher answered 25/7, 2014 at 21:15 Comment(0)
W
1

Years ago I used Slide Splitter for Impress for this same exact need. Worked with ppt slides as well and exporting to .jpeg.

Witenagemot answered 1/10, 2010 at 19:4 Comment(4)
Is there an up to date link for this?Elise
@Elise The only one I could find is at sourceforge.net/projects/ooomacros/files/Slide%20SplitterWitenagemot
WARNING! The link seems infected with a trojan virus.Coniah
sourceforge is infected with a virus? you may want to notify them.Witenagemot
C
1

We can convert pptx to pdf and then pdt to JPEG images using imagemagick. Here is what works for me on Ubuntu.

First we need to install several packages:

apt update && apt install libreoffice imagemagick ghostscript

Now, convert pptx file to PDF using the following command:

soffice --headless --convert-to pdf test.pptx

The generated PDF file is named test.pdf. Then we can use imagemagick to convert PDF to jpeg image:

# you can tweak density and quality to change the quality of generated images.
convert -density 150 test.pdf -quality 80 output-%3d.jpg

In case that you encounter errors when running the above command. Edit /etc/ImageMagick-6/policy.xml and change the following line:

<policy domain="coder" rights="none" pattern="PDF" />

to

<policy domain="coder" rights="read|write" pattern="PDF" />

Ref: This answer is based on post here.

Crossgarnet answered 4/9, 2020 at 12:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.