SIMPLE OVERLOADED FUNCTION: Adds TTF Center and Right Alignment to co ordintate points.
Correctly demonstrates the use of the bouning box TTF function and the array of coordinates that it returns.
After obtaining values and adjusting based on a set of values [L, C, R], it uses simple math based of the length of the text to move it from the origin (x = 0 )
function imagettftextalign($image, $size, $angle, $x, $y, $color, $font, $text, $alignment='L')
{
//check width of the text
$bbox = imagettfbbox ($size, $angle, $font, $text);
$textWidth = $bbox[2] - $bbox[0];
switch ($alignment) {
case "R":
$x -= $textWidth;
break;
case "C":
$x -= $textWidth / 2;
break;
}
//write text
imagettftext ($image, $size, $angle, $x, $y, $color, $font, $text);
}
?>
http://www.white-hat-web-design.co.uk/blog/php-captcha-security-images/http://kr.php.net/manual/pt_BR/function.imagettfbbox.php
댓글 0
- 전체
- Android+iPhone+etc.
- Apache+Tomcat
- ASP
- ASP.NET
- DataBase
- HTML / CSS
- JavaScript
- JSP
- Linux Server
- PHP
- Raspberry pi
- Windows Server
- WIPI
- Etc.