国内最大的酷站演示中心!
随时给自己贴的图片加文字
<?
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);
?>