|
użytkowników online: 24
|
OPINIE UŻYTKOWNIKÓW
|
Gratulacje i dzięki! Trafiłem tu przypadkiem poszukując informacji na temat php+mysql. Wiele polskich stron powiela identyczne przykłady, klonuje te same kursy i lekcje... ten serwis okazał sie inny. Zasada "problem - rozwiazanie - wyjaśnienie" zdaje egzamin - zapewnia jasną, jednoznaczną i pewną pomoc w konkretnym przypadku. Porady są warte swojej ceny, przede wszystkim ze względu na przyjazną (także dla początkujących) formę i treść oraz bogate i stale powiększane zasoby. Polecam i pozdrawiam!
Kamil Dmowski
Polski Czerwony Krzyż
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
imagefontheight (PHP 3, PHP 4, PHP 5) imagefontheight -- Get font height
User Contributed Notesdev at numist dot net
25-Jan-2005 12:47
This library function is very useful for variable-sized images that only contain text, like this function that I use to output error messages that accumulate and cause a fatal error in my thumbnailer:
<?php
function errimg($error) {
$font_size = 2;
$text_width = imagefontwidth($font_size);
$text_height = imagefontheight($font_size);
$width = 0;
$height = count($error);
for($x = 0; $x < count($error); $x++) {
if(strlen($error[$x]) > $width) {
$width = strlen($error[$x]);
}
}
$width = $width * $text_width;
$height = $height * $text_height;
$im = imagecreatetruecolor($width + ( 2 * $text_width ),
$height + ( 2 * $text_height ) );
if($im) {
$text_color = imagecolorallocate($im, 233, 14, 91);
for($x = 0; $x < count($error); $x++) {
imagestring($im, $font_size, $text_width,
$text_height + $x * $text_height, $error[$x],
$text_color);
}
out($im, array(), $error);
} else {
$error[] = "Is GD Installed?";
die(var_dump($error));
}
}
?>
The function expects an array of error messages to be passed in, and then outputs an image containing the contents of the array. This is especially useful if your code is contained in an html page that will display rexes if the images do not render correctly.
This function displays the array in image form with index 0 at the top, and the highest index at the bottom.
You have to write out() yourself though, see imagejpeg, imagepng, etc for good ideas on how to write a decent output function.
|