Submitted by Daniel McFeeters on
As a pastor, I find myself often struggling to manage the unwieldy beast that is PowerPoint. Call me a bit of a maverick, but I still use an Ubuntu-powered laptop with LibreOffice, and I find that it's sufficient for my needs, and I love the flexibility and power of BASH scripting and other command-line "magic." Nonetheless, sometimes I need to make a presentation and then display it from a different computer at church, only to find that my text boxes are broken because the other computer lacked the fonts, or interpreted a gradient or transparency differently. And by the time I realize that, I'm up front and being embarrassed by my terrible looking slides! It would be great to just have a simple script to "dumb down" a powerpoint, burn everything to graphics and just show that, rather than my original presentation.
With a bit of help from ChatGPT, I made a script that does just that. It takes a PowerPoint or LibreOffice file, converts it to PDF and then to JPEG. Then it converts those JPEG files back to a new PDF and then finally back to PowerPoint, with all text and filters permanently "burned" in to each slide.
With very little work, this script could be adapted do a variety of tasks, such as created a PowerPoint from a collection of images, or converting the PowerPoint to images, or PDF, etc.
Copy the script below, save it to a file such as "compile_powerpoint.sh", then make it executable (chmod +x compile_powerpoint.sh). You will need to be sure that GhostScript, ImageMagick, and LibreOffice are installed, and likely you'll need to adjust the path for LibreOffice from what I have below.
You will also want to open a file in Impress and export it to PDF once, making sure to uncheck the box to export presenter notes. This step is needed only to get the setting saved so that you don't end up with presenter notes as slides in your final output!
Then simply ./compile_powerpoint.sh MyPowerPoint.pptx, and you should get a file called MyPowerPoint.compiled.ppt
This file should have all your slides, but every slide will be internally burned down to a single graphic, and it should work anywhere. All presenter notes, videos, and animations will be missing, though.
#!/bin/bash # # Simplify a presentation to work on any computer by converting # all slides to JPEG files and then combining them back into # a powerpoint file that doesn't require any special fonts # or filters # # OPTIONS LIBREOFFICE=/opt/libreoffice24.2/program/soffice.bin RESOLUTION=1920x1080 JPEGQ=88 #!/bin/bash # Check if a parameter is provided if [ $# -eq 0 ] || [ "$1" == "--help" ]; then echo "Usage: $0" exit 1 fi # Get the absolute path of the specified file FILE=$(realpath "$1") # Check if the file exists if [ ! -f "$FILE" ]; then echo "Error: File '$FILE' does not exist." exit 1 fi # Check if the LibreOffice exists if [ ! -f "$LIBREOFFICE" ]; then echo "Error: LibreOffice executable does not exist at $LIBREOFFICE." echo "Please edit the constants in this script to specify the correct path" exit 1 fi # Check if the file is in the current directory if [ "$(dirname "$FILE")" != "$(pwd)" ]; then echo "Error: Please specify a file in the current directory." exit 1 fi # Create a folder to work in mkdir .working # Convert Presentation to PDF $LIBREOFFICE --headless --convert-to pdf "$1" --outdir ./.working cd .working mv *.pdf tmp.old.pdf # Convert PDF to individual JPEG slides gs -sDEVICE=jpeg -o slide-%03d.jpg -g$RESOLUTION -dPDFFitPage -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -dJPEGQ=$JPEGQ tmp.old.pdf rm tmp.old.pdf # Use ImageMagick to combine JPEG slides into a new PDF convert slide-*.jpg tmp.new.pdf rm slide-*.jpg # Convert new PDF back to PowerPoint PPTX $LIBREOFFICE --headless --infilter="impress_pdf_import" --convert-to ppt tmp.new.pdf rm tmp.new.pdf BASENAME="${1%.*}" # Move the output file back to original directory and finish cleanup mv tmp.new.ppt "../$BASENAME.compiled.ppt" cd .. rmdir .working