Oneliner: text to image using imagemagick

$ convert -size 200x30 xc:transparent -font /usr/share/fonts/dejavu/DejaVuSansMono.ttf -fill black -pointsize 12 -draw "text 5,15 'this is just a test'" test.png

The result:

With this oneliner it’s very easy to create images of e-mail addresses for anti-spam purposes (pretty old-fashioned though).

2 Responses to “Oneliner: text to image using imagemagick”

  1. Ahti
    April 17th, 2009 | 13:20
    Using Mozilla Firefox Mozilla Firefox 3.0.8 on Windows Windows Vista


  2. Severin
    June 8th, 2010 | 10:34
    Using Mozilla Firefox Mozilla Firefox 3.5.9 on Ubuntu Linux Ubuntu Linux

    Add -trim +repage to fit the image to the text. Addionally, set the x coordinate to zero and match the y coordinate to the point size to get a centered text:

    convert -size 200×30 xc:transparent -font /usr/share/fonts/truetype/ttf-dejavu/DejaVuSansCondensed.ttf -fill black -pointsize 16 -draw “text 0,16 ‘this is just a test'” -trim +repage test.png

Leave a reply