ppmlabel -x 50 -y 50 -text hello \ -angle -30 -text there \ testimg.ppm
This program is part of Netpbm.
ppmlabel uses the text drawing facilities of libnetpbm's "ppmd" component to add text to a PBM image. You control the location, size, baseline angle, color of the text, and background color (if any) with command line arguments. You can specify the text on the command line or supply it in files.
You can add any number of separate labels in a single invocation of ppmlabel, limited only by any restrictions your environment has on the number and size of program arguments (e.g. a shell's command size limit).
If you don't specify ppmfile, ppmlabel reads its input PPM image from Standard Input.
The output image goes to Standard Output.
A more sophisticated way to add a label to an image is to use pbmtext or pbmtextps to create an image of the text, then pamcomp to overlay it onto the base image.
Another more general program is ppmdraw. It is slightly harder to use for simple labelling.
The arguments on the ppmlabel command line are not options in the strict sense; they are commands which control the placement and appearance of the text being added to the input image. They are executed left to right, and any number of arguments may appear.
You can abbreviate any option to its shortest unique prefix.
Specify the color (color) as described for the argument of the ppm_parsecolor() library routine.
-colour is an acceptable alternate spelling.
Note that if you invoke ppmlabel via a shell command and your text string contains spaces, you'll have to quote it so the shell treats the whole string as a single token. E.g.
$ ppmlabel -text "this is my text" baseimage.ppm >annotatedimage.ppm
Text strings are restricted to 7 bit ASCII. The text font used by ppmlabel doesn't include definitions for 8 bit ISO 8859/1 characters.
When drawing multiple lines of text with a non-transparent background, it should probably fill the space between the lines with the background color. This is tricky to get right when the text is rotated to a non-orthogonal angle.
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, without any conditions or restrictions. This software is provided ``as is'' without express or implied warranty.