Created
April 6, 2015 19:01
-
-
Save hpurmann/31c4d4b5c2c5acfa31b3 to your computer and use it in GitHub Desktop.
Convert tex to png, per folder or per file. http://hpurmann.com/2015/04/12/gitdags-my-workflow/
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 | |
texPath="_graphs" | |
outPath="graphimages" | |
tmpPath="tmp" | |
png_density="300"; # convert -density | |
png_quality="90"; # convert -quality | |
function convert_file { | |
f=${1} | |
echo "Processing ${f} ..."; | |
filename=${f##*/} | |
cd ${texPath}; | |
mkdir -p ${tmpPath} | |
pdflatex -output-directory=${tmpPath} ${filename} # > /dev/null | |
cd ".."; | |
convert -density ${png_density} ${texPath}/${tmpPath}/${filename%.tex}.pdf -quality ${png_quality} ${outPath}/${filename%.tex}.png | |
rm -r ${texPath}/${tmpPath} | |
} | |
if [ ${#} == 0 ]; | |
then | |
echo "Processing all tex files in ${texPath} ..."; | |
for f in ${texPath}/* | |
do | |
convert_file ${f} | |
done | |
else | |
fileName=${1} | |
convert_file ${fileName} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment