How to add text 1\'/" on a picture

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
jueljust

How to add text 1\'/" on a picture

Post by jueljust »

I wanna place text 1\'/" on a picture

then i input the follow command in shell

Code: Select all

convert -fill red -font /arial.ttf -pointsize 30 -draw "text 50, 150 '1\\\'/\"' " /src.jpg /dist.jpg
then i got an error message

Code: Select all

convert: Non-conforming drawing primitive definition `/'.
and text 1\ was placed on the dist.jpg

please told me how to add this text, and what's my problem

regards
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: How to add text 1\'/" on a picture

Post by anthony »

You are dealing with quotes within quotes within a shell.
This in turn make it very difficult to determine the number of backslashes needed.

As you used double quotes for the argument the shell will remove all backslashes as part of its escape mechanism unless they are doubled.
Further more regarless of the internal quotes used, IM -draw will also escape (and remove) baclshashes that are not doubled.

That is you need to double then quadruple a backslash to get one single backslash.

you have a few options. first, don't use -draw. use -annotate That only has a single quote system, so you only need to handle shell escaping. next if you don't need to substitute shell variables into the argument, use single quotes. That will eliminate the shell escaping mechanism.

For more details see IM Examples, To Quote or Backslash?
http://imagemagick.org/Usage/draw/#quote
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
jueljust

Re: How to add text 1\'/" on a picture

Post by jueljust »

thank you so much, it very helpful!
Post Reply