BASH script: Generate PNG image with text from CLI

A nice little BASH script which generates a PNG image (black on white by default) from a text source (eighter from a pipe or stdin until you press CTRL+D).
#!/bin/bash
if [ "$1" = "--help" ] ; then
echo -e "Usage:\
Pipe some text into $0 with filename as an optional parameter."
exit 1
fi
if [ -n "$1" ] ; then
file="$1"
else
file="cli-"`date +%s`".png"
fi
echo "Saving to: $file"
cat | convert label:@- $file

Once again inspired by commandlinefu.com:
http://www.commandlinefu.com/commands/view/9104/save-command-output-to-image 

No comments:

Post a Comment