Portál AbcLinuxu, 5. května 2024 02:03


Dotaz: imagettfbbox

17.4.2006 23:30 makara | skóre: 13
imagettfbbox
Přečteno: 209×
Odpovědět | Admin
Dobry. Mam taky problem chcem spravit v php Secure Code obrazok. A pri pouziti funkcie imagettfbbox mi to vypisuje chybu Call to undefined function , ale pritom mam nainstalovane nove GD a free-type a php nepozna tu funkciu. Ma to generovat nahodny text z *.ttf fontov ale kedze nemam naistalovane graficke prostredie tak neviem kde tie fonty mam nakopirovat. Mam distribuciu Slackware 10.1, Apache 1.3.33 , php 4.3.10 , gd 2.0.28.
Tu je ukazka z toho scriptu
//Select Font
$font = "arial.ttf";

//Select random background image
$bgurl = rand(1, 3);
$im = ImageCreateFromPNG("images/bg".$bgurl.".png");

//Generate the random string
$chars = array("a","A","b","B","c","C","d","D","e","E","f",
"K","l","L","m","M","n","N","o","O","p","P","q","Q","r","R",
"V","w","W","x","X","y","Y","z","Z","1","2","3","4","5","6",);
$length = 8;
$textstr = "";
for ($i=0; $i<$length; $i++) {
   $textstr .= $chars[rand(0, count($chars)-1)];
}

//Create random size, angle, and dark color
$size = rand(12, 16);
$angle = rand(-5, 5);
$color = ImageColorAllocate($im, rand(0, 100), rand(0, 100), rand(0, 100));

//Determine text size, and use dimensions to generate x & y coordinates
$textsize = imagettfbbox($size, $angle, $font, $textstr);
$twidth = abs($textsize[2]-$textsize[0]);
$theight = abs($textsize[5]-$textsize[3]);
$x = (imagesx($im)/2)-($twidth/2)+(rand(-20, 20));
$y = (imagesy($im))-($theight/2);

//Add text to image
ImageTTFText($im, $size, $angle, $x, $y, $color, $font, $textstr);

//Output PNG Image
header("Content-Type: image/png");
ImagePNG($im);

//Destroy the image to free memory
imagedestroy($im);
Nic nieje take tazke aby to clovek sam nakoniec nevyriesil :)
Nástroje: Začni sledovat (0) ?Zašle upozornění na váš email při vložení nového komentáře.

Na otázku zatím nikdo bohužel neodpověděl.

Založit nové vláknoNahoru

Tiskni Sdílej: Linkuj Jaggni to Vybrali.sme.sk Google Del.icio.us Facebook

ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.