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 Link to comment https://forums.phpfreaks.com/topic/19591-gd-text-to-image/ 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. Link to comment https://forums.phpfreaks.com/topic/19591-gd-text-to-image/#findComment-85237 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 Link to comment https://forums.phpfreaks.com/topic/19591-gd-text-to-image/#findComment-85257 Share on other sites More sharing options...
CanMan2004 Posted September 3, 2006 Author Share Posted September 3, 2006 Thanks Link to comment https://forums.phpfreaks.com/topic/19591-gd-text-to-image/#findComment-85289 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.