[prev in list] [next in list] [prev in thread] [next in thread] 

List:       graphicsmagick-help
Subject:    Re: [GM-help] Generate Image from text containing double quotes
From:       Bob Friesenhahn <bfriesen () simple ! dallas ! tx ! us>
Date:       2014-03-16 20:45:16
Message-ID: alpine.GSO.2.01.1403161534141.1735 () freddy ! simplesystems ! org
[Download RAW message or body]

On Fri, 14 Mar 2014, ioannis wrote:

> In order to generate an image from a String, I am using the following
> command:
>
> gm convert -size 300x -background white -pointsize 15 -font Arial
> caption:string text example.jpg
>
> The above command is executed using
> org.gm4java.engine.support.PooledGMService.
> This works fine, unless if I need to print text that contains double
> quotes.
> In Linux/OSX, if text contains double quotes I need to escape them, and
> surround text with double quotes.
> This prints the text correctly, but the surrounding double quotes are
> also printed, and I cannot find a way to stop that. Single quotes inside
> text don't cause problems. Windows does not print the surrounding
> quotes, and requires them anyway, but the code will be mainly be run on
> linux.
>
> Any suggestions about how to solve this problem with quotes?
> ps: I have tried using label instead of caption, but it ignores the
> pointsize set, and instead takes all the available width.

Trying to get the Unix/Windows command shell and argument strings to 
all behave and pass what you want into the program is really hard. 
With some effort, it is possible with a Unix shell but Windows command 
shell only understands double qotes

It does seem to work to put the text into a file and use it by 
reference (via @ prefix on file name).  In this case doubled quotes 
were not required:

~~~~~~~~~~~~~~~~~~~
% cat hi.txt
Hi" There
% gm convert -size 300x -background white -pointsize 15 -font Arial caption:@hi.txt example.jpg
~~~~~~~~~~~~~~~~~~~

Of course this requires a temporary file and you still need to figure 
out how to get your literal text in there.

Using text files by reference under Windows is a good idea since it 
avoids the many weaknesses associated with the Windows command shell 
and command-line length limits.  It is good enough that the Visual 
Studio compiler still works like that to this day.

Bob
-- 
Bob Friesenhahn
bfriesen@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Graphicsmagick-help mailing list
Graphicsmagick-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-help
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic