欢迎光临
我们一直在努力

随时给自己贴的图片加文字-PHP教程,PHP应用

建站超值云服务器,限时71元/月

随时给自己贴的图片加文字

<?

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);

?>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 随时给自己贴的图片加文字-PHP教程,PHP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章