Skip to content

Instantly share code, notes, and snippets.

@gpollo
Created January 28, 2017 00:38
Show Gist options
  • Save gpollo/03b11a50346b660d55ddf5d3683636e3 to your computer and use it in GitHub Desktop.
Save gpollo/03b11a50346b660d55ddf5d3683636e3 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
wget "http://www.polymtl.ca/sc/logos_normes/logo.php" 2> /dev/null
mkdir -p eps svg tex
cd eps
cat ../logo.php | grep -Po '(?<=href=")[^"]*' | grep -i eps | cut -c 4- | while read EXT; do
if [[ $(echo "$EXT" | grep bloc) ]]; then
continue
fi
LINK="http://www.polymtl.ca/sc/$EXT"
EPS=$(basename "$LINK")
SVG="$(echo $EPS | rev | cut -c 5- | rev).svg"
TEX="$(echo $EPS | rev | cut -c 5- | rev).tex"
printf "Downloading $LINK\n"
wget "$LINK" 2> /dev/null
printf "Converting to SVG $SVG\n"
inkscape "$EPS" --export-text-to-path --export-plain-svg="$SVG" > /dev/null
printf "Converting to PGF/TikZ $TEX\n"
svg2tikz "$SVG" > "temp"
printf "Formatting LaTeX file $TEX\n"
cat temp | sed 's/\\documentclass{article}/\\documentclass{standalone}\n\\usepackage{standalone}/g' \
| sed 's/yscale/scale=\\logoscale, yscale/g' \
| sed 's/\\begin{document}/\\def\\logoscale{1}\n\\begin{document}/g' \
> "$TEX"
done
cd ..
printf "Moving files..."
find "./eps" -type f -iname "*.svg" -exec mv -v '{}' svg \;
find "./eps" -type f -iname "*.tex" -exec mv -v '{}' tex \;
cd tex
printf "Downloading extra logo\n"
wget "https://raw.githubusercontent.com/TheNiceGuy/gphys/master/src/poly.tex" 2> /dev/null
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment