Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert pptx files to jpg or png (for each slide) on linux?

I want to convert a powerpoint presentation to multiple images. I already installed LibreOffice on my server and converting docx to pdf is no problem. pptx to pdf conversion does not work. I used following command line:

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

Is there es way to convert pptx to pngs immediately or do I have to convert it to pdf first and then use ghostscript or something?

And what about the quality settings? Is there a way to choose the resolution of the resulting images?

Thanks in advance!

EDIT: According to this link I was able to convert a pdf to images with the simple command line:

convert <filename>.pdf <filename>.jpg 

(I guess you need LibreOffice and ImageMagick for it but not sure about it - worked on my server)

But there are still the problems with the pptx-to-pdf convert.

Thanks to googling and Sebastian Heyn's help I was able to create some high quality images with this line:

convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg

Please be patient after using it - you still can type soemthing into the unix console but it's processing. Just wait a few minutes and the jpg files will be created.

For further information about the options check out this link

P.S.: The aspect ratio of a pptx file doesn't seem to be exactly 4:3 because the resulting image size is 1950x1500

like image 421
user2718671 Avatar asked Feb 03 '14 09:02

user2718671


People also ask

Can we convert Microsoft PowerPoint slides into a picture or image File?

Click to open the Save as Type drop-down menu. Select one of the following image formats for your slide. Click Save. Review the PowerPoint dialog box, and select Just This One to save your selected slide as an image.


2 Answers

After Installing unoconv and LibreOffice you can use:

unoconv --export Quality=100 filename.pptx filename.pdf 

to convert your presentation to a pdf. For further options look here.

Afterwards you can - as already said above - use:

convert -density 400 my_filename.pdf -resize 2000x1500 my_filename%d.jpg 

to receive the images.

like image 75
user2718671 Avatar answered Sep 19 '22 20:09

user2718671


Convertion PPTX to PNG/JPG

This solution requires LibreOffice ( soffice ) and Ghostscript ( gs )

sudo apt install libreoffice ghostscript

Then two steps:

  1. PPTX -> PDF
soffice --headless --convert-to pdf prezentacja.pptx
  1. PDF -> PNG/JPG
gs -sDEVICE=pngalpha -o slajd-%02d.png -r96 prezentacja.pdf
  • -o slajd-%02d.png - output to file, %02d slajd number, two digits
  • -r96 - resolution:
    • 96 -> 1280x720
    • 144 -> 1920x1080
like image 24
NiKO Avatar answered Sep 18 '22 20:09

NiKO