How to convert .pptx slides to .jpg or .png images on Linux in command line?

How to convert .pptx slides to .jpg or .png images on Linux in command line?

This following method works best for me.

First, convert .pptx file to .pdf using libreoffice:

libreoffice --headless --convert-to pdf file.pptx

--headless makes libreoffice run in batch mode and not start the GUI. The pdf file will be named file.pdf by replacing the .pptx with .pdf in the original file name.

Second, convert .pdf file to .jpg using convert:

convert -density 400 -resize 3000^ file.pdf file%d.jpg

-resize 3000^ specifies the width in px of the image files. .jpg images will be named file0, file1, file2, … numbered following the slide numbers.

Eric Ma

Eric is a systems guy. Eric is interested in building high-performance and scalable distributed systems and related technologies. The views or opinions expressed here are solely Eric's own and do not necessarily represent those of any third parties.

One comment:

  1. Thanks, Mr. Ma! That worked perfectly on a headless Raspberry Pi. For people who only want to run this from command line, I highly recommend `apt install libreoffice-nogui` which saved a lot of storage space.

    Also, I was able to use `pdfimages -all file.pdf file` to extract the embedded images from the slides, which was all that I needed. It operates instantly, as opposed to `convert` which is slow, but isn’t generally useful since it doesn’t actually draw the slides. (It’ll be missing text, for example.)

Leave a Reply

Your email address will not be published. Required fields are marked *