Convert words/files to images


after a short discussion yesterday about safe registration and using images with text I decided it’s about time I learn how to create images from words on the command line. Or even better, generate a HTML file, made of images, from a GNU Xnee source file.

[Added after original post: scripts can be found here]

OK, here’s a file that takes a word as its first argument and a filename as second:


export PRIMARY=”-size 800×120 xc:white ”
export TEXT_PRIMARY=”-fill black -annotate +20+80 ”
export TEXT_SHADOW=” -fill red -annotate +21+81 ”
export TEXT_SHADOW2=” -fill yellow -annotate +22+82 ”
ARG=$( echo “$1” | sed -e ‘s,\\\\*,*,g’)
#echo “gen for \”$1\” –> \”$ARG\””
+repage $2

I named the file: word2png Here’s how to use it:

word2png “IFK” ifk.png

It’s about time for the next file. Read a text file (such as a header file in the Xnee sources), call word2png for every word in it, and add some HTML stuff. Here’s the file:



rm -fr ${TMP_DIR}
mkdir  ${TMP_DIR}
rm -f  ${IDX_FILE}

echo "$*" >> ${IDX_FILE}

whtml "html body"
if [ "$1" = "" ] ; then echo "Missing file arg....." ; exit 1 ; fi
if [ ! -f $1 ] ; then echo "Missing file arg....." ; exit 1 ; fi

echo "Using file: $1"
while read line
#  echo "read $line"
ARG=$( echo "$line" | sed -e 's,*,*,g'  -e 's,,,g'  )
for i in $ARG
./word2png "$i" ${TMP_DIR}/${CNT}.png
whtml ""
(( CNT++ ))
whtml "
done <  $1

whtml "/body /html "

echo "wrote to: $IDX_FILE"

I called it: file2png Here’s how to use it:

file2png xnee.h

Then open up the file /tmp/file2png/index.html in your browser.

I know it’s useless….. but I really think it’s kind of fun!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s