|
||||||
| PHP Tutorials PHP Tutorials |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||||
|
Quote:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||
|
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:
Quote:
![]() 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 |
|
|||||
|
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);
?>
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||
|
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 |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |
| 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 |
Goal: 100,000 Posts
Complete: 67%