Page 1 of 1
how to render a long text in an area with automatic wrap
Posted: 2015-04-03T15:09:43-07:00
by artex
Hello everyone,
with php I create this command for image composition that works. But I want to render the text in a box area of a width of 100px (es.).
Does anyone know tell me the parameters to give the text?
if I use-size parameter again for text area doesn't work
convert -size "500"x"500" xc:white -density "72"x"72" -units PixelsPerInch -draw "translate 0,0 image Over 0,0 425,425 "background.jpg"" -draw "translate 155,100 image Over 0,0 125,125 "image/sun.jpg"" -font "font_ttf/font_ttf/Helvetica.ttf" -pointsize "16" -fill "red" -draw "translate 130,240 text 0,0 'text i like wrap in a box area of 150px large!'" out.png
it is very urgent!
Tanks
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-03T15:26:21-07:00
by snibgo
"-draw text" doesn't word-wrap. "caption:" does. See
http://www.imagemagick.org/Usage/text/
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-04T01:18:27-07:00
by artex
Thanks,
how I have to specify the size of the box where render the text (es. 150 pixel large) ?
If I repeat -size parameter does'nt works.
Can you hlp me?
Thanks
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-04T08:05:03-07:00
by fmw42
try
Code: Select all
convert -background none -size 150x -fill black -font yourfont -pointsize PP caption:"your text here" result.png
Then composite this over your background image at the desired locations using -gravity and -geometry
Code: Select all
convert backgroundimage result.png -gravity ZZ -geometry +X+Y -compose over -composite finalresultimage
See
http://www.imagemagick.org/Usage/text/#caption
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/annotating/#gravity
http://www.imagemagick.org/script/comma ... p#geometry
http://www.imagemagick.org/script/comma ... hp#gravity
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-05T11:51:17-07:00
by artex
my I use -size parameter two time?
After your indication i have tried:
convert -size "500"x"500" xc:white -density "72"x"72" -units PixelsPerInch -draw "translate 0,0 image Over 0,0 425,425 "background.jpg"" -draw "translate 155,100 image Over 0,0 125,125 "image/sun.jpg"" -font "font_ttf/font_ttf/Helvetica.ttf" -pointsize "16" -fill "red" -draw "translate 130,240 -size 150x caption: 'text i like wrap in a box area of 150px large!'" out.png
but does'nt works.
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-05T12:42:54-07:00
by Bonzo
but does'nt works.
I am not surprised; I would work on one step at a time and when that works move onto the next - you have so many things going on it would be very hard to debug.
You will also need to use
parenthesis to group certain options.
It would be a good idea to link to an expected final output image so we know what you actually want.
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-05T14:02:03-07:00
by artex
But I start by a comand that works:
convert -size "500"x"500" xc:white -density "72"x"72" -units PixelsPerInch -draw "translate 0,0 image Over 0,0 425,425 "background.jpg"" -draw "translate 155,100 image Over 0,0 125,125 "image/sun.jpg"" -font "font_ttf/font_ttf/Helvetica.ttf" -pointsize "16" -fill "red" -draw "translate 130,240 text 0,0 'text i like wrap in a box area of 150px large!'" out.png
do you kow how insert caption parameter with -size in my comand?
(I have seen parenthesis link)
thanks
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-05T14:13:06-07:00
by fmw42
You need to learn to use parenthesis processing so that the arguments do not apply repeatedly to the wrong part of the code. Also break long commands into newlines using a trailing \ at the end of the section so that the code is readable. See
http://www.imagemagick.org/Usage/basics/#parenthesis.
-draw does not word wrap. you need to use caption and -size=Wx (not -size=WxH). See
http://www.imagemagick.org/Usage/text/
Re: how to render a long text in an area with automatic wrap
Posted: 2015-04-05T15:21:59-07:00
by snibgo
artex wrote:-draw "translate 130,240 -size 150x caption: 'text i like wrap in a box area of 150px large!'"
The syntax is wrong. "caption:" is not a valid option for "-draw".