The ppmcaption program adds text to images. Multiple blocks of text can be placed on the image, with varying fonts, font sizes, colors, and transparency.
Originally, I had just been using a set of PPM filters to add text to the images (with a pipeline consisting of various calls to pbmtext, pbmmake, pnmscale, pnmsmooth, etc.) but it was really slow: that pipeline took almost 20 seconds to process each image, due to all the redundant I/O. (At the time, ImageMagick's convert was even slower.) Combinations of PPM utilities can be very powerful, but not very fast. So I wrote a single standalone program that does the kinds of things I needed, and it's an order of magnitude faster. This is that program.
Here's a gaudy example of what it can do:
I created that image with the following command:
djpeg input.jpg | \ \ ppmcaption - - \ -font ncenB24.bdf -scale 0.7 -blur 12 -fg black -bg '#88FF88' \ -pos 240,30 -center -text 'http://www.dnalounge.com/' \ \ -font ncenB24.bdf -scale 0.45 -blur 2 -fg white -bg red \ -pos -80,80 -center \ -text 'Warning:%ndo not look%ninto laser with%nremaining eye.' \ \ -font ncenB24.bdf -scale 0.34 -blur 3 -fg black -bg white \ -pos 10,-10 -left -text DNA Lounge' \ -pos -10,-10 -right -text '%a, %d-%b-%Y %l:%M:%S %p %Z' \ \ -font ncenR24.bdf -scale 2.5 \ -pos 240,220 -opacity 0.2 -center -text 'ppmcaption%nwww.jwz.org' | \ \ cjpeg | \ wrjpgcom -replace -comment "...copyright notice..." > output.jpg
To compile the source code and install the program:
tar -vxzf ppmcaption-1.1.tar.gz cd ppmcaption-1.1/ ./configure make make install
You might want to build in a default font (plus effects): this will speed up startup of the program a lot. To do that, add arguments to the configure script like so:
./configure --with-builtin="ncenB24.bdf -scale 0.5 -blur 5"
Please let me know if you find any bugs or make any improvements.