CanMan2004 Posted September 3, 2006 Share Posted September 3, 2006 Hi allI have a simple text to image GD script[code]<?php header ("Content-type: image/png"); $handle = ImageCreate (275, 386) or die ("Cannot Create image"); $bg_color = ImageColorAllocate ($handle, 255, 255, 255); $txt_color = ImageColorAllocate ($handle, 0, 0, 0); ImageTTFText ($handle, 8, 180, 270, 360, $txt_color, "arial.ttf", "".$_GET['txt'].""); ImagePng ($handle); ?>[/code]It works when passing the URLwww.mysite.com/website/image.php?txt=this is a testThe script works fine, my question is, how can I get the text to word wrap, as it currently keeps all text onto the same line.Secondly, how can I get GD to understand line breaks in the url, for example, if I pass the textthis is a text<br>this is another test<br>this is the last testthen it shows all that on one line, and prints in the text <br>that is the same if you replace <br> with \nAny help would be greatThanks in advanceEd Quote Link to comment Share on other sites More sharing options...
.josh Posted September 3, 2006 Share Posted September 3, 2006 i only have simple knowledge of the gd library, just enough to do a little customization of captcha type scripts, but i don't think the gd library specifically supports that. I think you are going to have to write your own function with conditions and some regexing and then create the image with the text using specific x,y coordinates, based on # of lines, etc... but hey, i could be wrong. there might be some gd function already made that does all that for you. Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 3, 2006 Share Posted September 3, 2006 gd alone can't do what you want.Pass the multi-line text using an obvious delimiter between lines.At the start of your gd script, use the explode() function to separate that multi-line text into single lines.The size of the exploded array will let you define the vertical co-ordinate for each separate lineLoop thru' theImageTTFtext as many times as you have separate lines Quote Link to comment Share on other sites More sharing options...
CanMan2004 Posted September 3, 2006 Author Share Posted September 3, 2006 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.