Note. This answer was the answer to the original version of the question, in which it is not clear whether the text should be written on the image or the text should be embedded in the binary image file as metadata. This answer suggested the first. However, the question has been edited to clarify what this means. This answer remains unchanged if someone is looking for a solution for the former.
convert -draw "text 20,20 'hello, world'" input.png output.png
20,20 in the example above is the coordinate in which I want to place the text.
You need to use the imagemagick package to get this command.
On Ubuntu or Debian, you can install it using the command: aptitude install imagemagick .
Here is a slightly more complicated use of the command:
convert -font Helvetica -pointsize 20 -draw "text 20,20 'hello, world'" Hypercube.png output.png
source share