Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a background color to drawn text

Tags:

imagemagick

Using ImageMagick 6.8.1, my goal is to add text to the bottom left corner of an image and to have that text's background be black. Essentially, I want something like a 20x20 black area in the bottom left corner of my image and that black area to have some text. I've gotten everything figured out except for the black background portion.

This is what I have so far: convert in.tif -pointsize 10 -background "#000000" -fill white -gravity SouthWest -draw "text 0,0 'a'" out.tif)

like image 467
user5923 Avatar asked Feb 01 '14 19:02

user5923


1 Answers

Try this, what you are looking for undercolor instead of background. Undercolor only fills the area covered by the text.

convert in.tif  -undercolor Black -pointsize 10 -fill white  -gravity SouthWest -annotate 0 'Text String' out.tif
like image 57
user3233109 Avatar answered Nov 18 '22 11:11

user3233109