随时给自己贴的图片加文字
发表于:2007-07-01来源:作者:点击数:
标签:
随时给自己贴的图片加文字 ? Header( Content-type: image/jpeg); function makethumb($srcFile,$text,$size=12,$R=0,$G=0,$B=0) { if(!$text){ $text=@#welcome xs .net .ru xayle@#; $size=20; $R=255; } $data = GetImageSize($srcFile,$info); switch ($d
随时给自己贴的图片加文字
<?
Header( "Content-type: image/jpeg");
function makethumb($srcFile,$text,$size=12,$R=0,$G=0,$B=0) {
if(!$text){
$text=@#welcome xs
.net.ru xayle@#;
$size=20;
$R=255;
}
$data = GetImageSize($srcFile,&$info);
switch ($data[2]) {
case 1: //图片类型,1是GIF图
$im = @ImageCreateFromGIF($srcFile);
break;
case 2: //图片类型,2是JPG图
$im = @imagecreatefromjpeg($srcFile);
break;
case 3: //图片类型,3是PNG图
$im = @ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
$ni= imagecreatetruecolor($srcW,$srcH);
imagecopyresampled($ni,$im,0,0,0,0,$srcW,$srcH,$srcW,$srcH);
$font = "2.ttf";
$textcolor = imagecolorallocate($ni,$R,$G,$B); // Set text color
$i=0;
$txt=@#@#;
$len=ceil((12*22)/$size);
$lgg=ceil(($size*16)/12)-1;
while(strlen($txt)>0||!$i){
$start=$len*$i;
$kk=ceil($size*13/12);
//$kk=13;
$txt=substr($text, $start, $len);
$hei=$i*$lgg+$kk;
imagettftext($ni,$size, 0, 8, $hei, $textcolor, $font, $txt); // Write the text with a font
$i++;
}
ImageJpeg($ni);
}
if(!$size||$size<1)$size=12;
makethumb("face.jpg",$text,$size,$R,$G,$B);
?>
原文转自:http://www.ltesting.net