封裝的可以控制往圖片上寫字,控制字符間距的方法

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

}

封裝的可以控制往圖片上寫字,控制字符間距的方法

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章