ziverd
Guest
Проблема с вызовом функции imagettfbbox() .
Есть проблемка.
Сделал я сайт значит, основная задача которого наносить текст на изображение.
Вот текст скрипта , который это делает:
На локалхосте всё работает замечательно(исползую appserv-win32-2.4.4a) , а как выложил в инет, вот такая ошибка при выполнении скрипта:
Call to undefined function: imagettfbbox() in
/home/fxride/public_html/print/new/make_button.php on line 30
Не знаю что и делать, писал админам хостинга(neahost.ru),написали вот что:
попробуйте изменить вызов функции
извините но на данную проблему мы не можем Вам сообщить конкретного
решения
Как видите, тоже ничего хорошего, так что вся надежда на этот форум, а очtym надо чтоб скрипт заработал.
Есть проблемка.
Сделал я сайт значит, основная задача которого наносить текст на изображение.
Вот текст скрипта , который это делает:
PHP:
<?
// check we have the appropriate variable data
// variables are button-text and color
if (empty($button_text) )
{
echo "Could not create image - form not filled out correctly";
exit;
}
// create an image of the right background and check size
$im = imagecreatefromgif ("$name-great.gif");
$width_image = ImageSX($im);
$height_image = ImageSY($im);
// Our images need an 18 pixel margin in from the edge image
$width_image_wo_margins = $width_image - (2 * 2);
$height_image_wo_margins = $height_image - (2 * 2);
// Work out if the font size will fit and make it smaller until it does
// Start out with the biggest size that will reasonably fit on our buttons
$font_size = 16;
do
{
$font_size--;
// find out the size of the text at that font size
$bbox=imagettfbbox ($font_size, 0, "arial.ttf", $button_text);
$right_text = $bbox[2]; // right co-ordinate
$left_text = $bbox[0]; // left co-ordinate
$width_text = $right_text - $left_text; // how wide is it?
$height_text = abs($bbox[7] - $bbox[1]); // how tall is it?
} while ( $font_size>8 &&
( $height_text>$height_image_wo_margins ||
$width_text>$width_image_wo_margins )
);
if ( $height_text>$height_image_wo_margins ||
$width_text>$width_image_wo_margins )
{
// no readable font size will fit on button
echo "Text given will not fit on button.<BR>";
}
else
{
// We have found a font size that will fit
// Now work out where to put it
$text_x = 30;
$text_y = 50;
if ($left_text < 0)
// add factor for left overhang
$above_line_text = abs($bbox[7]); // how far above the baseline?
$text_y += $above_line_text; // add baseline factor
$text_y -= 2; // adjustment factor for shape of our template
$white = ImageColorAllocate ($im, 255, 255, 255);
ImageTTFText ($im, $font_size, 0, $text_x, $text_y, $white, "arial.ttf",
$button_text);
$font_size = 33;
do
{
$font_size--;
// find out the size of the text at that font size
$bbox=imagettfbbox ($font_size, 0, "arial.ttf", $button_text1);
$right_text = $bbox[2]; // right co-ordinate
$left_text = $bbox[0]; // left co-ordinate
$width_text = $right_text - $left_text; // how wide is it?
$height_text = abs($bbox[7] - $bbox[1]); // how tall is it?
} while ( $font_size>8 &&
( $height_text>$height_image_wo_margins ||
$width_text>$width_image_wo_margins )
);
if ( $height_text>$height_image_wo_margins ||
$width_text>$width_image_wo_margins )
{
// no readable font size will fit on button
echo "Text given will not fit on button.<BR>";
}
else
{
// We have found a font size that will fit
// Now work out where to put it
$text_x = $width_image/2.0 - $width_text/2.0;
$text_y = $height_image/2.0 - $height_text/2.0 ;
if ($left_text < 0)
// add factor for left overhang
$above_line_text = abs($bbox[7]); // how far above the baseline?
$text_y += $above_line_text; // add baseline factor
$text_y -= 2; // adjustment factor for shape of our template
$white = ImageColorAllocate ($im, 255, 255, 255);
ImageTTFText ($im, $font_size, 0, $text_x, $text_y, $white, "arial.ttf",
$button_text1);
Header ("Content-type: image/png");
ImagePng ($im);
}
Header ("Content-type: image/png");
ImagePng ($im);
}
ImageDestroy ($im);
?>
Call to undefined function: imagettfbbox() in
/home/fxride/public_html/print/new/make_button.php on line 30
Не знаю что и делать, писал админам хостинга(neahost.ru),написали вот что:
попробуйте изменить вызов функции
извините но на данную проблему мы не можем Вам сообщить конкретного
решения
Как видите, тоже ничего хорошего, так что вся надежда на этот форум, а очtym надо чтоб скрипт заработал.