您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2025/7/17 7:18:33发布30次查看
header( content-type: image/jpeg); 
function makethumb($srcfile,$text,$size=12,$r=0,$g=0,$b=0) { 
if(!$text){ 
$text=''welcome to imbbs.cn''; 
$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||$sizemakethumb(face.jpg,$text,$size,$r,$g,$b); 
?>
以上就介绍了php代码 随时给自己贴的图片加文字的php代码,包括了php代码方面的内容,希望对php教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product