Anthony Tribby on  wrote...
| I am having a similar problem, about which I have posted to this list  
| preivously.
| 
| I can get caption or label to accurately render newlines if I put  
| them directly into the command line, but as I am allowing users to  
| input text, there can be characters such as apostrophes which screw  
| up the command line, so I have been writing the text into a file and  
| then having IM read from there. There problem is that when IM reads  
| the file back in, suddenly it is just rendering the "\n" characters  
| instead of seeing them as newlines.
| 
| Any suggestions?
| 
Then you can NOT use the '@file' to read from file or pipe, as that
turns off such escapes, as you discovered.  However if YOU convert the
"\n" to newline characters yourself, you will have no problems.

You also do not have to write it to a file!!!!
use popen() (pipe open) type call, and print your file into stdin of the
command, reading it using a "caption:@-" argument.


WARNING: the free type library does not understand control sequences
such as TAB, FORMFEED, etc. whcih IM passes through unchanged.
using such characters often results in some random 'glyph' from the
font being used.


Okay assuming you want to allow uses to use escapes, like %c %w %h \n.
then you MUST use a command line argument.

WARNING: Watch out and backslash any initial '@' characters, you don't
want them typing    '@/etc/passwd'!


Now apostrophes only screws up the commandline  IF the shell interprets
it.  If you are using an API such as PHP or Perl to handle things, then
call the commands without using the shell, but you need to also do the
argument separation yourself.

EG:  in perl use a argument form of system call...

   system( 'convert', '-size', '100x', "caption:$user_caption",
                    '...', '...', '...', 'gif:-' );
or even...
   system( 'convert',
      -size      => '100x',
      -pointsize => 18,
      "caption:$user_caption",
      ...
      'gif:-' );

I am sure PHP has a 'shell-less' type command call too.

In perl if you have a large number of constant space separated works
you and also use...  qw{ ...} to quote words...

   system( qw{ convert -size 100x }, "caption:$user_caption",
              qw{ ... ... ... ... gif:- }

I don't think PHP has that.

Of course if you don't have a shell you can not do shell pipelines,
feeding the output of one command into another.



Refer to the Security section of your API language manuals, thye usally
have a lot of hints and tips about avoiding the shell in external
command calls.


  Anthony Thyssen ( System Programmer )    <[EMAIL PROTECTED]>
 -----------------------------------------------------------------------------
  Ivoniva:   "Lets get out of here.  We are running out of time."
  Zatheris:  "Can not run out of time! There is infinite time!
              You are finite.  Zatheris is finite."
                                             -- Bablyon 5, ``War Without End''
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users

Reply via email to