Last active
September 30, 2020 06:01
-
-
Save evertdespiegeleer/048197be1ac7b727decf0130b2a698d7 to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Script by Evert De Spiegeleer | |
# 29/09/2020 | |
help_usage () { | |
echo " | |
--- usage --- | |
rasterizePdf <inputFile> <outputFile> | |
Both the inputfile and outputfile need to have the .pdf-extension. | |
" | |
} | |
if [[ -z "$1" || -z "$2" ]] ; then # Check if needed args are provided | |
help_usage | |
elif [ -f "$1" ] ; then | |
echo "Converting $1 to a rasterized version... This can take a while." | |
{ | |
mkdir ./.pdfConversionTempFolder && convert -density 300 $1 ./.pdfConversionTempFolder/image%03d.png && convert ./.pdfConversionTempFolder/*.png $2 && rm -r ./.pdfConversionTempFolder/* && rm -rf ./.pdfConversionTempFolder && printf "\a" | |
} &> /dev/null | |
echo "Wrote rasterized pdf to $2." | |
else | |
echo "Inputfile $1 not found." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment