Page 1 of 1

imagettfbbox() problem

Posted: Tue Nov 11, 2003 6:34 am
by vigge89
When running this script on my hosts server;

Code: Select all

<?php
//Text to print
$txt = @$_GET['txt'];
if(empty($txt)) { $txt = "vigge89"; };

//Font settings
$font = "HOOG0550.ttf";
$fsize = "6";

$h = 7;	//Height

//Center
$text_bbox = ImageTTFBBox ($fsize, 0, $font, $txt);
$img_width = $text_bbox[2]-$text_bbox[0] + 2 ;

//Create image
$im = imagecreate ($img_width, $h);

//Color setup

$r = @$_GET['r']; // Red
if(empty($r)) { $r = "255"; };
$g = @$_GET['g']; //Green
if(empty($g)) { $g = "255"; };
$b = @$_GET['b']; //Blue
if(empty($b)) { $b = "255"; };

//Set colors
$bc = ImageColorAllocate ($im, 0,0,0); //Background
$fc = ImageColorAllocate ($im, $r,$g,$b); //Text

//Write text from variables
ImageTTFText ($im, $fsize, 0, 1, 6, $fc, $font, $txt);

//Create image
header ("Content-type: image/png");
ImagePNG ($im);
?>
I get the error:
Fatal error: Call to undefined function: imagettfbbox() in C:\Webserver\apache\htdocs\vigge\source\image.php on line 18

GD Library is installed, and also Freetype 2, but what should my host do to make it work?

It works on my local server (ApacheFriends XAMPP for windows Version 1.0), but not on his.

Posted: Tue Nov 11, 2003 7:47 am
by twigletmac
Does GD appear if you do:

Code: Select all

echo '<pre>';
print_r(get_loaded_extensions());
echo '</pre>';
Mac

Posted: Tue Nov 11, 2003 7:49 am
by vigge89
nope, just:
[0] => standard
[1] => bcmath
[2] => calendar
[3] => com
[4] => ftp
[5] => mysql
[6] => odbc
[7] => pcre
[8] => session
[9] => xml
[10] => wddx

Posted: Tue Nov 11, 2003 8:00 am
by vigge89
I succeded in creating my own string-lenght checker :D ;

Code: Select all

<?php
	//Check number of characters
	$img_width = strlen($txt) * 6;

	//Check if there are any special chars
	$numI = substr_count($txt, "i"); //I's
	$numspc = substr_count($txt, "_"); //_'s
	$num1 = substr_count($txt, "1"); //1's
	$numdots = substr_count($txt, "."); //.'s
	$numsep = substr_count($txt, "-"); //-'s

	//If there is, change the lenght of image
	If ($numI > 0) { $img_width = $img_width - ($numI * 2); };
	If ($numspc > 0) { $img_width = $img_width - ($numspc * 3); };
	If ($num1 > 0) { $img_width = $img_width - ($num1 * 3); };
	If ($numdots > 0) { $img_width = $img_width - ($numdots * 2); };
	If ($numsep > 0) { $img_width = $img_width - ($numsep * 4); };
?>
it works great when using pixel fonts, which i am using :)

Posted: Tue Nov 11, 2003 8:05 am
by vigge89
worked great on my local server, but not on my hosts one :(
ImageCreate is undefined :/
Doesn't seem like my host did install GD Lbraray at all :(

Posted: Tue Nov 11, 2003 8:06 am
by vigge89
deleted

Posted: Tue Nov 11, 2003 8:06 am
by twigletmac
No, GD is not listed in the loaded extensions so it has not been enabled on your hosts server.

Mac