Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A ImageMagick question

Status
Not open for further replies.

Kruzer

Programmer
Jun 16, 2000
117
US
Has anyone worked with Text::Wrap?<br><br>Here's my problem - I have a image dimension of 125 X 125 and a graphic string that extends past the width 125 to 130 and so on.&nbsp;&nbsp;So far I've come to the conclusion that Text::wrap is the way to go.&nbsp;&nbsp;<br><br>Here's my attempt<br><br>use Text::Wrapper;<br>use POSIX qw(floor);<br>...<br><br>&Text::wrap::columns = POSIX::floor(125/5);<br>&text = wrap(&quot;&quot;,&quot;&quot;,&text);<br>$image-&gt;Annotate(text=&gt;$text);<br><br>The code runs without any errors, but it just doesn't work!<br>
 
well without even looking at the module i'd say your problem is the following line:<br><br>&text = wrap(&quot;&quot;,&quot;&quot;,&text);<br><br>perhaps you mean:<br><br>$text = wrap(&quot;&quot;,&quot;&quot;,$text);<br><br>and if you did not want to draw in both the wrap module and the posix module you could do somthing like:<br><br>$len = int 125/5;<br>$text =~ s/(.{$len})(?:[^\n])/$1\n/g;<br><br>if your $len never changed as in this case and the replacement ran more than once in the program you might want to add the o flag to the substitution while you are at it. <br><br><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top