Last active
June 27, 2020 18:16
-
-
Save ryananeff/2fdd77e4611f2cd89ba32c9fdb6fa10c to your computer and use it in GitHub Desktop.
[MacOS] Reduce the size of PowerPoint (*.pptx) files by converting internal images from TIFF to PNG, saving 30x in file size
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| input_file=$1; | |
| if unzip -l "${input_file}" | grep ".tiff" | |
| then | |
| echo "tiffs found, converting..." | |
| unzip -q "${input_file}" -d test | |
| for i in test/ppt/media/*.tiff; do sips -s format png "${i}" --out "${i%tiff}png"; rm $i; done | |
| for i in test/ppt/slides/_rels/*.rels; do echo $i; sed -i -e 's/.tiff/.png/g' $i; done | |
| rm test/ppt/slides/_rels/*.rels-e; | |
| cd test/; | |
| zip -q -r -X ../tmp.pptx * | |
| cd ..; | |
| rm -r test; | |
| mv tmp.pptx "${input_file}"; | |
| echo "converted tiffs in ${input_file}." | |
| else | |
| echo "no tiffs found in file" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment