$image = ImageCreateFromJPEG( "img/6.jpg" ); $cor = imagecolorallocate($image, 0, 0, 0); $font = ‘debiao.ttf‘; $tt = ‘我们的灵魂‘; $a = im($image, 120, 0, 150, 150, $cor, $font, $tt,50); header(‘Content-type: image/jpeg‘); imagejpeg($image); function im(&$image, $size, $angle, $start_x, $y, $color, $font, $text,$spancing) { for ($i=0;$i<mb_strlen($text,‘utf8‘);$i++) { $t = mb_substr($text, $i,1,‘utf8‘); $x = $i*($size+$spancing); imagettftext($image, $size, $angle, $x+$start_x, $y, $color, $font, $t); } }
封装的可以控制往图片上写字,控制字符间距的方法
原文地址:http://chenxiaolong.blog.51cto.com/8786841/1716746