How I can use Line Break like this with imagemagick
-
- Posts: 44
- Joined: 2014-11-28T16:19:41-07:00
- Authentication code: 6789
How I can use Line Break like this with imagemagick
Hi,
i found http://stackoverflow.com/questions/3577 ... magemagick
and it have
$draw = new ImagickDraw();
$x = 0;
$y=20;
$angle = 0;
$padding = 10;
$str = "some text for testing of a word wrap in imagemagick";
$str = wordwrap($str, 10,"\r");
$str_array = explode("\n",$str);
foreach($str_array as $line)
$im->annotateImage( $draw, $x, $y+$padding, $angle, $line );
}
to line break, I need to use this code with php and imagemagick and exec command.
any help please?
i found http://stackoverflow.com/questions/3577 ... magemagick
and it have
$draw = new ImagickDraw();
$x = 0;
$y=20;
$angle = 0;
$padding = 10;
$str = "some text for testing of a word wrap in imagemagick";
$str = wordwrap($str, 10,"\r");
$str_array = explode("\n",$str);
foreach($str_array as $line)
$im->annotateImage( $draw, $x, $y+$padding, $angle, $line );
}
to line break, I need to use this code with php and imagemagick and exec command.
any help please?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I can use Line Break like this with imagemagick
This code is using Imagick API. It is not directly usable for PHP exec(). You would have to create the equivalent command line code with unix shell or windows batch script to do the looping and extract each word from the list.
This is a simple solution:
see
http://www.imagemagick.org/Usage/text/# ... ne-spacing
change the -gravity to west if you want it aligned on the left side.
This is a simple solution:
Code: Select all
convert -background white -gravity center -fill black -font Arial -pointsize 18 -interline-spacing 10 \
label:"some\ntext\nfor\ntesting\nof\na\nword\nwrap\nin\nimagemagick" result.gif
http://www.imagemagick.org/Usage/text/# ... ne-spacing
change the -gravity to west if you want it aligned on the left side.
-
- Posts: 44
- Joined: 2014-11-28T16:19:41-07:00
- Authentication code: 6789
Re: How I can use Line Break like this with imagemagick
hi
i have problem like: viewtopic.php?t=19249
i do not want to use /n because i get the text from input form.also i need to change something , but i can use the wordwrap to explode text with /n.
for example : I have a input like:
This code is using Imagick API. It is not directly usable for PHP . You would have to create the equivalent command line code with unix shell or windows batch script to do the looping and extract each word from the list.
i can explode /n it and my result will be:
line1 - This code is using Imagick API. It is not directly usable for PHP .
line2 - You would have to create the equivalent command line code with unix shell or
line3 - windows batch script to do the looping and extract each word from the list.
so i need to draw first line 3 then line 2 and then line1
is it possible?
i have problem like: viewtopic.php?t=19249
i do not want to use /n because i get the text from input form.also i need to change something , but i can use the wordwrap to explode text with /n.
for example : I have a input like:
This code is using Imagick API. It is not directly usable for PHP . You would have to create the equivalent command line code with unix shell or windows batch script to do the looping and extract each word from the list.
i can explode /n it and my result will be:
line1 - This code is using Imagick API. It is not directly usable for PHP .
line2 - You would have to create the equivalent command line code with unix shell or
line3 - windows batch script to do the looping and extract each word from the list.
so i need to draw first line 3 then line 2 and then line1
is it possible?
Re: How I can use Line Break like this with imagemagick
Code: Select all
$draw = new ImagickDraw();
$x = 0;
$y=20;
$angle = 0;
$padding = 10;
$str = "some text for testing of a word wrap in imagemagick";
$str = wordwrap($str, 10,"\r");
$str_array = explode("\n",$str);
foreach($str_array as $line)
$im->annotateImage( $draw, $x, $y+$padding, $angle, $line );
}
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I can use Line Break like this with imagemagick
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.
If you do not want to manually insert \n, then you can automate that. Try this ($text can come from your form element). This is just PHP exec compatible. If you need to use Imagick, then do what user bonzo suggested above.
Some PHP expert should correct my quoting in the exec command if it is wrong.
If you do not want to manually insert \n, then you can automate that. Try this ($text can come from your form element). This is just PHP exec compatible. If you need to use Imagick, then do what user bonzo suggested above.
Code: Select all
$text="some text for testing of a word wrap in imagemagick"
$newtext=str_replace(" ", "\n", $text);
exec("convert -background white -gravity center -fill black -font Arial -pointsize 18 -interline-spacing 10 \
label:"."$newtext"." result.gif");
-
- Posts: 44
- Joined: 2014-11-28T16:19:41-07:00
- Authentication code: 6789
Re: How I can use Line Break like this with imagemagick
Hi fred, you true, i got my answer, but this topic is about line auto break in imagemagick, thank you for answer and thanks bonzo.
i will try that.
i will try that.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I can use Line Break like this with imagemagick
You can do automatic line breaks (not word breaks) by using caption: or pango: instead of label:
see
http://www.imagemagick.org/Usage/text/#caption
http://www.imagemagick.org/Usage/text/#pango
try this:
You just need to specify the width and pointsize and IM will automatically break the line where needed.
see
http://www.imagemagick.org/Usage/text/#caption
http://www.imagemagick.org/Usage/text/#pango
try this:
Code: Select all
text="some text for testing of a word wrap in imagemagick"
convert -background white -size 200x -gravity center -fill black -font Arial -pointsize 18 -interline-spacing 10 \
caption:"$text" result.gif
-
- Posts: 44
- Joined: 2014-11-28T16:19:41-07:00
- Authentication code: 6789
Re: How I can use Line Break like this with imagemagick
it's true, but also i told already, in need draw lines, revers... first 3, then 2, then 1
i found a way to draw persian or arabic text without pango , just imagemagick and some php code, i will share that with imgaemaick ORG very soon,
i hope that use full.
best regards.
i found a way to draw persian or arabic text without pango , just imagemagick and some php code, i will share that with imgaemaick ORG very soon,
i hope that use full.
best regards.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I can use Line Break like this with imagemagick
I have no idea what lines you want to draw. If you mean rows of text, that is what caption: did. If you want to draw a word at a time, then the label process works just fine.but also i told already, in need draw lines
So I am not sure what kind of result you are trying to achieve.
If you have found a way to do that, then please show us your code and resulting image.
-
- Posts: 44
- Joined: 2014-11-28T16:19:41-07:00
- Authentication code: 6789
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I can use Line Break like this with imagemagick
What does this have to do with your original question at the top of this topic, regarding the code you provided? Please keep the posts to one subject; otherwise, it gets very confusing for people to answer your questions. Did you resolve the original question?
-
- Posts: 44
- Joined: 2014-11-28T16:19:41-07:00
- Authentication code: 6789
Re: How I can use Line Break like this with imagemagick
but topic is about line break fred,
I open a new topic and explain about the code.
thank you
I open a new topic and explain about the code.
thank you
-
- Posts: 44
- Joined: 2014-11-28T16:19:41-07:00
- Authentication code: 6789
Re: How I can use Line Break like this with imagemagick
what is your idea about the results?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How I can use Line Break like this with imagemagick
Sorry, I am confused. I do not see any line breaks in your examples above. So I do not connect those results to the title of your topic.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How I can use Line Break like this with imagemagick
Pango wordwrap (automatic newlines) seems to work correctly for Arabic. For example (Windows BAT syntax):
Code: Select all
convert ^
-size 200x200 -gravity Center ^
-background khaki ^
-font Arial -pointsize 50 ^
pango:"صَوْرة سِحْر" ^
u8_pa_a2ww.png
snibgo's IM pages: im.snibgo.com