Basically the draw test syntax is
text X Y "text"
commas between arguments are optional, but some form of quoting (single or double) is NOT.
Draw also requires its whole argument string as a single argument so the shell needs quotes around that
As such the result is (with some extra spacing)
HOWEVER, if the variable itself has quotes in it -- you have problems, as the shell expands the variabel, and draw sees the extra quotes!
See IM Exmaples, Draw, To Quote or Backslash?
http://www.imagemagick.org/Usage/draw/#quote
The better method is
-annotate whcih removed the need for that extra level or quoting, though adds escape sequences instead.
IM Examples, Text to Image handling, Annotate
http://www.imagemagick.org/Usage/text/#annotate
fmw42 wrote:In Unix, variable must be enclosed by double quotes to be resolved.
Almost. The shell much expand the variable as it is what is holding the variables value.
If the variable contains spaces, and quotes, then you MUST wrap that variable in double quotes to preserve those characters (single quotes does not expand shell varables).
Because of this, always wrapping variable expansion in double quotes is a very good rule of thumb for almost all situations.
NOTE: the missing quotes (within the shell parsed quotes) is for the Draw operator's syntax. The quote could actually be included in the shell variable itself!!!
Code: Select all
my_text='"quoted text"'
convert -size 100x100 xc: -draw "text 10,50 $my_text" show:
here the variable supplies draw with the quotes for its syntax. The quotes themselves are not 'drawn'
however here they are
Code: Select all
convert -size 100x100 xc: -draw "text 10,50 '$my_text' " show:
But the draw 'MSVG string' parser will get confused in the variable contained single quotes!
To see what the draw parser sees, 'echo' the draw string
Code: Select all
echo "text 10,50 '$my_text' "
text 10,50 '"quoted text"'
The shell will have stripped its quoting, and all spaces and other character (apart from a final newline added by echo) printed on screen is what is passed to ImageMagick for just that one argument.
Finally the IMv7 "magick" script passer was designed to parse quotes and backslashes in exactly the same way as the UNIX "bash" shell. Especially in regard to backslashing and quoting of newlines.