1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
$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
);
}
}
|
封装的可以控制往图片上写字,控制字符间距的方法
|
本文转自 陈小龙哈 51CTO博客,原文链接:
http://blog.51cto.com/chenxiaolong/1716746
|