homepage Welcome to WebmasterWorld Guest from 54.196.196.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP with created image write text and text pt problem
PHP with created image write text and text pt problem
erkin0007




msg:4583028
 7:43 am on Jun 11, 2013 (gmt 0)

Hi
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">
</form>';
if(isset($_POST['text'])){
$text=$_POST['text'];
$image = imagecreate(300,300);
$background = imagecolorallocate($image, 250, 0, 0);//color
$imagecolor = imagecolorallocate($image, 0, 0, 0);
imagestring($image, 454, 6,5 , "$text", $imagecolor);
imagepng($image,"images/test.png");
sleep(2);// my pc is slow
imagedestroy($image);
}



$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]

 

jatar_k




msg:4583130
 2:35 pm on Jun 11, 2013 (gmt 0)

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

erkin0007




msg:4583137
 3:07 pm on Jun 11, 2013 (gmt 0)

User will write the article. And it doesn't pass to down because the line is full

rainborick




msg:4583149
 3:26 pm on Jun 11, 2013 (gmt 0)

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.

erkin0007




msg:4583482
 2:49 pm on Jun 12, 2013 (gmt 0)

so text punto?
how we set to text punto?
i create new font?because i want to characters are big

DrDoc




msg:4583639
 10:53 pm on Jun 12, 2013 (gmt 0)

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.

erkin0007




msg:4583756
 7:52 am on Jun 13, 2013 (gmt 0)

thank you

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved