Using PHP and GD to add border to text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<?php
@author @param @param @param @param @param @param @param @param @param @param @see http://us.php.net/manual/en/function.imagettftext.php
function imagettfstroketext(&$image, $size, $angle, $x, $y, &$textcolor, &$strokecolor, $fontfile, $text, $px) {
for($c1 = ($x-abs($px)); $c1 <= ($x+abs($px)); $c1++)
for($c2 = ($y-abs($px)); $c2 <= ($y+abs($px)); $c2++)
$bg = imagettftext($image, $size, $angle, $c1, $c2, $strokecolor, $fontfile, $text);
return imagettftext($image, $size, $angle, $x, $y, $textcolor, $fontfile, $text);
}
|
1
2
3
4
5
6
|
<?php
$img = imagecreatefrompng("/home/john/Desktop/test.png");
$font_color = imagecolorallocate($img, 0, 0, 0);
$stroke_color = imagecolorallocate($img, 255, 0, 0);
imagettfstroketext($img, 10, 0, 10, 50, $font_color, $stroke_color, "abstract.ttf", "Hello, World!", 2);
?>
|
Tags: border, gd, PHP, stroke, text
May 7th, 2010 at 5:36 pm
so good
it helped me a lot
thanks
June 12th, 2010 at 11:49 pm
Good brief and this post helped me alot in my college assignement. Gratefulness you on your information.