Skip to content

Instantly share code, notes, and snippets.

@pwl
Created September 16, 2010 23:06
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 pwl/583334 to your computer and use it in GitHub Desktop.
Save pwl/583334 to your computer and use it in GitHub Desktop.
#!/bin/bash
function print_n {
cat participants.tex\
| tr '\n' ' '\
| sed -e 's|\\Partic{|\n|g' -e 's| *| |g' -e 's|\x27|\\\x27|g' -e 's|} *{|}{|g' \
| awk -F'}{' 'NR > 1 {print $1 ":" $2 ":" $3}'
}
IFS=$'\x0a'
surnamefont="/usr/share/fonts/type1/gsfonts/a010013l.pfb"
surnamesize=50%
namesize=50%
affiliationsize=20%
badgesize=400x200
ext=png
partic=$(print_n)
convert -size $badgesize xc:lightblue "template.$ext"
rm -f badges/*
for n in $partic; do
# name=
# echo $n
surname=$(echo "$n"|awk -F':' '{print $1}')
name=$(echo "$n"|awk -F ':' '{print $2}')
affiliation=$(echo "$n"|awk -F ':' '{print $3}')
echo "$surname"
convert "template.$ext" -background lightblue -fill blue \
-font $surnamefont -pointsize $surnamesize -gravity east\
-draw "text 10%,-50% '$name'" \
"badges/$surname.$ext"
convert "badges/$surname.$ext" -fill red \
-font $surnamefont -pointsize $namesize -gravity east\
-draw "text 10%,0 '$surname'" \
"badges/$surname.$ext"
convert "badges/$surname.$ext" -fill red \
-font $surnamefont -pointsize $affiliationsize -gravity southeast\
-draw "text 10%,10% '$affiliation'" \
"badges/$surname.$ext"
done
rm -f Page*
find badges/ -name "*.$ext"| split -l10 -d - Page
for f in $(ls -1 Page*); do
files=$(cat $f)
montage $files -tile x5 -geometry +2+2 -background black pages/$f.png
done
rm -f Page*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment