Lost Password?

  #21 (permalink)  
Old 05-09-2007, 07:05 AM
v0id's Avatar   
v0id v0id is offline
Super Moderator
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,445
Last Blog:
CherryPy(thon)
Rep Power: 27
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

Quote:
hello! nice tutorial!! i was just wondering if you know how to wrap the text into a nice paragraph if the string is too long to fit onto the image?
This, http://php.net/wordwrap, may helps you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #22 (permalink)  
Old 05-09-2007, 07:12 AM
snailofsatan snailofsatan is offline
Newbie
 
Join Date: May 2007
Posts: 4
Rep Power: 0
snailofsatan is on a distinguished road
Default

sorry to be a pain, but i'm a bit new to this GD stuff! do you know how i can implement the php word wrap into the GD code below?

Quote:
<?php
$text = "The quick brown fox jumped over the lazy dog.";
$newtext = wordwrap($text, 20, "<br />\n");

echo $newtext;
?>

Quote:
<?php
header('Content-type: image/png');
$text = $_GET['text'];

$im = imagecreatefrompng ("userbar.png");

$color = imagecolorallocate($im, 0, 0, 0);

$font = 'font.ttf';
$fontsize = 6;
$size = imagettfbbox($fontsize, 0, $font, $text); //calculate the pixel of the string
$dx = (imagesx($im)) - (abs($size[2]-$size[0])) - 20; //calculate the location to start the text
imagettftext($im, $fontsize, 0, $dx, 13, $color, $font, $text);
imagepng($im);
imagedestroy($im);
?>
thanks in advance for any help/tips!

ps if i use $newtext in the GD code, won't it ignore the <br>s and /n's and just show the code as text? or will it process them and move down to a new line?
kev

Last edited by snailofsatan; 05-09-2007 at 07:15 AM. Reason: addition
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #23 (permalink)  
Old 05-09-2007, 07:18 AM
v0id's Avatar   
v0id v0id is offline
Super Moderator
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,445
Last Blog:
CherryPy(thon)
Rep Power: 27
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

I've no experience with PHP and GD, so it may be wrong.

In your code, from PHP.net, you have first a variable, $text, with some text. hen your wordwraps it, and get a new text into the variable $newtext. In the other code, from this tutorial, you also need some text. The text is used in imagettfbbox() and imagettftext(). They both use the variable, $text, with is the content of the GET, "text". Because of that, you simply have to wordwrap that variable, and then then text of it will be used in the following code.

Code:
<?php
header('Content-type: image/png');

// ------------------------------------------------------
// This is the changed line...
$text = wordwrap($_GET['text'], 20, "<br />\n");
// ------------------------------------------------------

$im = imagecreatefrompng ("userbar.png");

$color = imagecolorallocate($im, 0, 0, 0);

$font = 'font.ttf';
$fontsize = 6;
$size = imagettfbbox($fontsize, 0, $font, $text); //calculate the pixel of the string
$dx = (imagesx($im)) - (abs($size[2]-$size[0])) - 20; //calculate the location to start the text
imagettftext($im, $fontsize, 0, $dx, 13, $color, $font, $text);
imagepng($im);
imagedestroy($im);
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #24 (permalink)  
Old 05-09-2007, 07:23 AM
snailofsatan snailofsatan is offline
Newbie
 
Join Date: May 2007
Posts: 4
Rep Power: 0
snailofsatan is on a distinguished road
Default

thankyou i'll give it a whirl!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #25 (permalink)  
Old 05-09-2007, 07:25 AM
snailofsatan snailofsatan is offline
Newbie
 
Join Date: May 2007
Posts: 4
Rep Power: 0
snailofsatan is on a distinguished road
Default

oh no, almost! rather that making a new line where each <br> \n is.. it just shows that text.. (rather than processing it)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #26 (permalink)  
Old 05-13-2007, 09:28 PM
TkTech TkTech is offline
 
Join Date: Jun 2006
Posts: 896
Last Blog:
Having trouble with yo...
Rep Power: 20
TkTech is on a distinguished road
Send a message via MSN to TkTech
Default

Very nice sidewinder, I'm impressed at the time you spent on that. Next up, you may want to dig into using PHP,GD, and Flash together. PHP can generate images using GD and then spice them up with the flash code PHP can create.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #27 (permalink)  
Old 05-14-2007, 01:12 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,731
Last Blog:
Passwords
Rep Power: 20
John has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud ofJohn has much to be proud of
Send a message via AIM to John
Default

I've been looking into using flash with php, the only thing I've been able to come up with is outputting information using xml, and have a flash action script read the xml.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #28 (permalink)  
Old 05-22-2007, 03:03 AM
sido sido is offline
Newbie
 
Join Date: May 2007
Posts: 2
Rep Power: 0
sido is on a distinguished road
Default

Quote:
To view attachments your post count must be 1 or greater. Your post count is 0 momentarily.
so.. let's try it... but looks very interesting.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #29 (permalink)  
Old 06-05-2007, 02:34 PM
angusi angusi is offline
Newbie
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0
angusi is on a distinguished road
Default

nice tut, just need to try it out now
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #30 (permalink)  
Old 06-19-2007, 05:20 PM
seozus seozus is offline
Newbie
 
Join Date: Jun 2007
Posts: 1
Rep Power: 0
seozus is on a distinguished road
Default

Real nice tutorial, this site is a real discovery
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP:Tutorial - Email Verification John PHP Tutorials 3 09-19-2007 12:19 PM
PHP:Tutorial The Date John PHP Tutorials 0 01-10-2007 06:10 PM


All times are GMT -5. The time now is 03:38 AM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
LogicKills ........ 20.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 67%

Ads