|PHP with created image write text and text pt problem|
PHP with created image write text and text pt problem
I am makin picture with imagecreate than I am showing tobackground with imagecolorallocate and I am printing with imagestring, my problem is ' I can't set this article's height, I wanna set it's height and I wanna to when the line was be full , it will pass to down
pt is punto
echo '<form action="" method="post">
<input type="text" name="text" id="text">
<input type="submit" value="submit">
$image = imagecreate(300,300);
$background = imagecolorallocate($image, 250, 0, 0);//color
$imagecolor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 454, 6,5 , "$text", $imagecolor);
sleep(2);// my pc is slow
$text is came to form.the user is determine($text)
[edited by: jatar_k at 2:32 pm (utc) on Jun 11, 2013]
[edit reason] fixed some funky chars [/edit]
Welcome to WebmasterWorld erkin0007,
I am not 100% sure if what you want
did you want to set an image you create to the background of an article but the article size is unknown?
obviously you can create whatever size you want with imagecreate but you need to have something to compare with.
I am unclear on this
>> when the line was be full , it will pass to down
User will write the article. And it doesn't pass to down because the line is full
The GD graphics library does not automatically break up lines of text to fit within the image boundaries. Your script must calculate the number of pixels required by the string you want to draw (the width), where you need to break the string into lines, and the x and y coordinates of each line to be drawn.
For short strings of one or two sentences, a simple calculation is acceptable. You just need to find the width of each character in the font you're using as well as an appropriate line-height, then use explode() to break the string into words. From there you can calculate where to break up the string into separate lines, and draw them on your image.
If you want to draw long strings consisting of several sentences, I would recommend you search Google for "php gd word wrap". You'll find a few examples of how to do this.
so text punto?
how we set to text punto?
i create new font?because i want to characters are big
The short answer is: you need to know the exact width of each character, then generate a properly word-wrapped string that is shorter than your maximum width.
You can either do this manually, or look into the solution recommended above. There is really no other way around this.