07/08/2007
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).
Filed by kargig at 19:14 under Internet,Linux,Privacy
2 Comments | 15,086 views
Yeah!
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