View Single Post
  #23 (permalink)  
Old 05-09-2007, 08:18 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,651
Last Blog:
CherryPy(thon)
Rep Power: 29
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);
?>
__________________
05-03-2007 - 11-13-2008
Reply With Quote