problems escaping quotes in image label

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
mattalexx

problems escaping quotes in image label

Post by mattalexx »

I'm using the text-to-image functionality. I want to be able to apply text that contains quotes, but I'm having a difficult time getting it to work. I want to be able to apply text that contains both single and double quotes.

Here's an attempt using a backslash, but it doesn't save the image at all:

Code: Select all

/usr/bin/convert -background 'rgb(255, 255, 255)' -fill 'rgb(250, 184, 5)' -font /[FONT_FOLDER]/OzHandicraftBT.ttf -pointsize 38 label:'page o\' clients' +trim /[MY_SAVE_FOLDER]/5a2c87ef6077ee551d1871dce412ade3.png
Then I tried writing a SQL-type escape by repeating the single quote. The image saved at least, but without the quote. Here's the command:

Code: Select all

/usr/bin/convert -background 'rgb(255, 255, 255)' -fill 'rgb(250, 184, 5)' -font /[FONT_FOLDER]/OzHandicraftBT.ttf -pointsize 38 label:'page o'' clients' +trim /[MY_SAVE_FOLDER]/5a2c87ef6077ee551d1871dce412ade3.png
What is the best solution to this problem. I would use double quotes to enclose the quote, but I want to be able to apply both single and double quotes to the same image.
mattalexx

Re: problems escaping quotes in image label

Post by mattalexx »

I've found the solution: Use double quotes to enclose the text and escape the double quotes witgh backslashes.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: problems escaping quotes in image label

Post by anthony »

this is a 'shell' problem in its interpretation of what is an argument.

double quotes is the right solution, single quotes can not escape themselves

this works though 'Anthony'\''s Examples'
I leave single quote mode, escape a quote, then re-enter single quote mode.


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