Page 2 of 2

Re: How I can use Line Break like this with imagemagick

Posted: 2014-12-02T06:18:28-07:00
by snibgo
I have updated my http://im.snibgo.com/snutf8.htm page to include Arabic examples, including word wrap and \n newlines.

Re: How I can use Line Break like this with imagemagick

Posted: 2014-12-02T18:13:20-07:00
by mostafanastary
Hi again,
i coding

$text = "I am not sure I understand your problem and the reference you provided. If it has to do with UTF8 characters, I believe you asked that before and got answers.";

$arrText=explode("\n",wordwrap($text,30,"\n"));

exec("convert -background white -gravity center -fill black -font tahoma.ttf -pointsize 18 -interline-spacing 10 label:$arrText[1] result.gif");

echo print_r($arrText);
echo printf($arrText);

when i print_r the $arrText Array, it echo:
Array ( [0] => I am not sure I understand [1] => your problem and the reference [2] => you provided. If it has to do [3] => with UTF8 characters, I [4] => believe you asked that before [5] => and got answers. )1

but result.gif is one word. i hope that draw """""your problem and the reference"""" in result as i point to $arrText[1] in exec command.
why? where is the problem?

Result:
Image

PS: i try "caption" too,

Re: How I can use Line Break like this with imagemagick

Posted: 2014-12-02T18:16:38-07:00
by mostafanastary
I have updated my http://im.snibgo.com/snutf8.htm page to include Arabic examples, including word wrap and \n newlines.
that good, but you use the pango, is it safe for server? because last update of pango in it website is too old

Re: How I can use Line Break like this with imagemagick

Posted: 2014-12-02T19:28:53-07:00
by fmw42
exec("convert -background white -gravity center -fill black -font tahoma.ttf -pointsize 18 -interline-spacing 10 label:$arrText[1] result.gif");

label: does not word wrap. And if you want all the text in $arrText[1], you need to put it in quotes, otherwise you get just the first word.

If you want word wrap, then you need to use caption: or pango: and specify some width with -size Wx. You can leave out height H, but you need the x. But caption does not seem to work reliably to word wrap with Arabic font and pango does word wrap, but does not center well. See snibgo's link above for examples.

Re: How I can use Line Break like this with imagemagick

Posted: 2014-12-03T06:53:30-07:00
by mostafanastary
Hi Fred, I code this command and it work very well. i test it with my new way for persian and arabic drawing text and work very good,

$text = 'I am not sure I understand your problem and the reference you provided. If it has to do with UTF8 characters, I believe you asked that before and got answers.';

$arrText=explode("\n",wordwrap($text,30,"\n"));
$n=0;
foreach($arrText as $arr)
{
exec("convert -background lightblue -fill blue -font tahoma.ttf -pointsize 36 -size 320x caption:'$arrText[$n]' result$n.png");
$n++;
}
this create result0.png,result1.png,and etc as $arr .