0
exec($IM_path."convert
    -size 800x300 xc:black  
    -font ".$linktottf."
    -pointsize 16
    -draw \"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"
    output.png");

The "draw text"-part in the code above doesn't work. the output.png displays only "Khle" … so there must be a problem with Special Characters, Whitespaces, Quotes, …

I tried a lot (escaping, different quotes, backslashes, …)

I've lost a lot of time now … so this is why I hope you could help me. Thx!

John Doe Smith
  • 1,623
  • 4
  • 24
  • 39

1 Answers1

1

if you want the quotes drawn as well you need to enclose them in a different set of quotes, double quotes wrapped in single quotes.

label:'\"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"'

As for the special characters try saving your script in unix utf-8 format (editors like Textpad have options for saving files as these when showing the save dialog, similar editors should have the same option).

And set the system LANG to use utf

LANG=en_US.utf-8;

exec("LANG=en_US.utf-8; ".$IM_path."convert -size 800x300 xc:black -font ".$linktottf." -pointsize 16 label:'\"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"' output.png");

Looks like you want 'label' and not draw. also it needs to be on one line otherwise it will interpret it as separate commands

Patrick Evans
  • 41,991
  • 6
  • 74
  • 87
  • hm.. your code does not work. are you sure that the LANG=en_US.utf-8;-part is at the right position .. and the quotes at the draw-line .. they'll break the string/cmd – John Doe Smith Jun 27 '13 at 08:24
  • yea wasnt fully done editing, the lang should be in the front of the path, wasnt paying attention that you were including the path for the convert. – Patrick Evans Jun 27 '13 at 08:51
  • oh sorry. now.. there is no output. if I delete the LANG-part there is one, but without text. so it still doesn't work .. – John Doe Smith Jun 27 '13 at 08:56
  • ok you need `label` or `caption` or similar others, not `-draw` to draw text, http://www.imagemagick.org/Usage/text/ – Patrick Evans Jun 27 '13 at 09:12
  • And dont forget to put the whole command on one line otherwise it iterperets the parts on new lines to be other commands. – Patrick Evans Jun 27 '13 at 09:19
  • and change your font color, you have the background black, and text gets rendered as black by default so – Patrick Evans Jun 27 '13 at 09:23
  • but now it's something totally different .. LANG=en_US.utf-8; still doesn't work! the "ü" is not displayed – John Doe Smith Jun 27 '13 at 10:03
  • did you also save the php script to utf-8 format like i mentioned? – Patrick Evans Jun 27 '13 at 10:37
  • i inserted header('Content-Type: text/html; charset=utf-8'); but it has no effect .. as long as i am using "LANG=en_US.utf-8;" it doesn't work .. means nothing works! – John Doe Smith Jun 27 '13 at 15:59
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/32507/discussion-between-patrick-evans-and-john-doe-smith) – Patrick Evans Jun 27 '13 at 16:01
  • Hey @JohnDoeSmith: What did you do to get it working. For same thing is happening. Command is working from command prompt but not from php. – Nilesh Apr 18 '17 at 15:03