Is it possible to get somehow the width of a text which one draws in image magick?
My current convert command looks like this:
convert -size 720x480 -background #000 xc:black -fill white -stroke white \ -font Arial -pointsize 18 \ -draw "text 72,370 'NavP1'" \ -font Arial -pointsize 18 \ -draw "text , ''" \ -font Arial -pointsize 18 \ -draw "text , ''" \ -font Arial -pointsize 18 \ -draw "text 370,370 'Extras'" \ -font Arial -pointsize 18 \ -draw "text 430,370 'opt'" \ -font Arial -pointsize 18 \ -draw "text 550,370 'NavP1'" \ C:\xampp\htdocs\labelText.bmp
I did this programmatically and want to center and align the navigation points to each other based on how many navigation points I have
( I get the number of navigation points from my php formular / database ).
Here is a little sketch of what I mean and how it should look like
________________________________________
| |
| |
| |
| navp1 navp2 |
|_______________________________________|
________________________________________
| |
| |
| |
| navp1 navp2 navp3 |
|_______________________________________|
I have a fixed width for that image (720px).
Thus I have a minimum number of 2 navigation points and a maximum number of 6 navigation points.
My thought is that if I could get the width of each Navigation (text/word) point I could calculate and align the points correctly.
But right know I could not find a function which does that.
I tried Mark Setchell Answer but my command seems to have a mistake
convert -debug annotate -size 720x480 -background #000 xc:black -fill white -stroke white \ -font Arial -pointsize 18 \ -draw "text 72,370 'nav1'" \ -font Arial -pointsize 18 \ -draw "text 180,370 'nav2'" \ -font Arial -pointsize 18 \ -draw "text 430,370 'nav3'" \ -font Arial -pointsize 18 \ -draw "text 550,370 'nav4'" \ C:\xampp\htdocs\test.bmp
but I get following error message:
no images defined '-background' @ error/convert.c/ConvertImageCommand/325
-size
settings, you don't need any of them other than the first as far as I can tell. Also,-font
, and-pointsize
are "settings", just the same as-fill
and-stroke
so they remain set until changed so you can remove all but the first of them. – Mark Setchell Jun 3 '16 at 8:47#
is a comment character, so you need to escape or quote it - or just useblack
– Mark Setchell Jun 3 '16 at 9:30