hp1 Posted September 21, 2007 Share Posted September 21, 2007 Hi all,I'm using GD to create images with 'quotes' in them. At the moment I am storing the quotes in an array but eventually I will probably store them in an external file so I can call them randomly. Before that I have a problem I need to solve. I fthe quote is wider than the image box then it just gets cut off. How do I tell it to wrap the text inside the boundary of the Image? Many Thanks <?phpheader("Content-type: image/png");$image = imagecreate( 200, 200);$pass['test1']="this is a test";$pass['test2']="This is a test2";$text=ImageColorAllocate($image, 200, 100, 100);$fill=ImageColorAllocate($image, 0, 0, 0);ImageFill($image, 0, 0, $fill); ImageString($image, 3, 30, 3, $pass['test2'], $text);imagepng($image);imagedestroy($image);?> Link to comment Share on other sites More sharing options...
hp1 Posted September 21, 2007 Author Share Posted September 21, 2007 OK i've now discovered the wordwrap function in php. Great, except where I have told it to break for a new line with a "\n" its inserting a funny symbol that looks like a small 'v' above a small 't' insetad of breaking for a new line. Is this something to do with the font perhaps? $newtext=wordwrap($pass['test2'], 20,"\n"); and then ImageString($image, 5, 5, 3, $newtext, $textcolor); cheers Link to comment Share on other sites More sharing options...
justsomeguy Posted September 24, 2007 Share Posted September 24, 2007 Print out the newtext string after you do the wordwrap to make sure that the string contains line breaks. Make sure to check the source code of the web page, the browser won't display the line breaks. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.