Jump to content


Photo

Some GD questions.


  • Please log in to reply
9 replies to this topic

#1 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 25 July 2006 - 02:52 PM

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 apple
I like oranges
Third line yeah = 3 lines * 14px = 42

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 25 July 2006 - 02:59 PM

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:
<?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';

?>


#3 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 25 July 2006 - 03:24 PM

ill give that a try and tell you haow it comes out. Thx for helping!

#4 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 25 July 2006 - 08:41 PM

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.

#5 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 08:46 PM

if you want to save a jpeg, put the path into the second argument of imagejpeg()
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#6 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 25 July 2006 - 09:32 PM

does that work the same with gifs? such as imagegif($im, file.gif);

#7 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 09:33 PM

yes
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#8 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 25 July 2006 - 09:40 PM

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 13
Maybe I have something wrong with my code. Here
<?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>';
} ?> 


#9 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 25 July 2006 - 09:53 PM

<?php
imagegif($im, "file.gif");
?>

Also make sure that the folder is writeable.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...

#10 foreverhex

foreverhex
  • Members
  • PipPipPip
  • Advanced Member
  • 91 posts

Posted 25 July 2006 - 10:41 PM

Ah, I think its the folder properties! Thx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users