Created
May 13, 2015 03:45
-
-
Save vmrob/ac9f44d18b5a5944bcaa to your computer and use it in GitHub Desktop.
Script to convert a pdf to png
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 -e | |
Root=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) | |
if [[ $1 == "" ]] ; then | |
echo "usage: generate-gitdag.sh input.tex [density (default 300)]" | |
exit; | |
fi | |
Density=300 | |
if [[ $2 != "" ]] ; then | |
echo "Using density of $2" | |
Density=$2 | |
fi | |
function cleanup() { | |
rm -rf $TempFolder | |
} | |
trap cleanup SIGTERM SIGINT | |
# TempFolder="Temp-$RANDOM" | |
TempFolder="Temp" | |
mkdir -p $TempFolder | |
BaseFileName=$TempFolder/$(basename $1 .tex) | |
Final=$(basename $1 .tex).png | |
# Other method, still a bug in imagemagick. Increase density greatly and | |
# resize to reduce artifacts | |
# max_print_line=200 latex -interaction batchmode -output-directory $TempFolder $1 | |
# dvisvgm $BaseFileName.dvi --color --output=$BaseFileName.svg | |
max_print_line=200 pdflatex -interaction batchmode -output-directory $TempFolder $1 | |
convert -density $Density -strip $BaseFileName.pdf $Final | |
cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment