foreverhex Posted July 25, 2006 Share Posted July 25, 2006 Ok so I have a form that takes text and make an image out of it. I was wanting to know, is there a way to make the text wrap around in the inside of the image, instead of just disapearing off the image? Also is there a function to count how many lines the text would have? So that the hieght of the image could be ajusted accordingly? Like:I am an appleI like orangesThird line yeah = 3 lines * 14px = 42 Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/ Share on other sites More sharing options...
wildteen88 Posted July 25, 2006 Share Posted July 25, 2006 You'll probably want to use wordwarp to addin a new line character every 20 characters. The use count and explode to get number of lines like so:[code]<?php$text = "The quick brown fox jumped over the lazy dog.";$newtext = wordwrap($text, 20, "<br />\n");echo $newtext . '<br /><br />';echo 'There are ' . count(explode("\n", $newtext)) . ' lines';?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63420 Share on other sites More sharing options...
foreverhex Posted July 25, 2006 Author Share Posted July 25, 2006 ill give that a try and tell you haow it comes out. Thx for helping! Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63432 Share on other sites More sharing options...
foreverhex Posted July 25, 2006 Author Share Posted July 25, 2006 Ok I tweaked what you gave me a bit and its all looking well thx. But, how do you save the file? I never really could understand the uploading scripts so Im not sure how you do this. Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63625 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 if you want to save a jpeg, put the path into the second argument of imagejpeg() Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63627 Share on other sites More sharing options...
foreverhex Posted July 25, 2006 Author Share Posted July 25, 2006 does that work the same with gifs? such as imagegif($im, file.gif); Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63649 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 yes Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63651 Share on other sites More sharing options...
foreverhex Posted July 25, 2006 Author Share Posted July 25, 2006 ok when I try to do that I get Warning: imagegif(): Unable to open 'filegif' for writing in /home/syblin83/public_html/testy.php on line 13Maybe I have something wrong with my code. Here[code]<?php$text = $_POST['poem'];if(isset($text)) {$newtext = wordwrap($text, 60, "\n", 1);$im = imagecreate (525, 400);$bgcolor = imagecolorallocate($im, 17, 0, 0);$fontcolor = ImageColorAllocate ($im, 255, 255, 255);imagecolortransparent($im, $bgcolor);ImageTTFText ($im, 11, 0, 1, 20, $fontcolor, "arial.ttf","$newtext");imagegif($im, file.gif);imagedestroy($im);} else {$page_name = ' :: Poetry';include 'top.php';echo '<table class=body align=left valign=top><tr valign=top><td align=left>';echo '<form action="testy.php" method="POST">Insert text here:<b>Discription:</b></td><td align=left><TEXTAREA Name=poem ROWS=8 COLS=40 style="color: #ffffff; background-color: #000000; border: solid #990000 1px; font-size: 12px;"></TEXTAREA><INPUT TYPE=Submit Value=" Upload Art " style="color: #00ff00; background-color: #000000; border: solid #990000 1px; font-size: 12px; width: 60px; height: 18px;"></form></td></tr></table>';} ?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63655 Share on other sites More sharing options...
ryanlwh Posted July 25, 2006 Share Posted July 25, 2006 [code]<?phpimagegif($im, "file.gif");?>[/code]Also make sure that the folder is writeable. Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63665 Share on other sites More sharing options...
foreverhex Posted July 25, 2006 Author Share Posted July 25, 2006 Ah, I think its the folder properties! Thx Quote Link to comment https://forums.phpfreaks.com/topic/15592-some-gd-questions/#findComment-63691 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.