Skip to content

Instantly share code, notes, and snippets.

@hpurmann
Created April 6, 2015 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpurmann/31c4d4b5c2c5acfa31b3 to your computer and use it in GitHub Desktop.
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/
#!/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