7
PHP를 사용하여 텍스트에서 이미지를 생성하는 스크립트가 있습니다. 다른 색상으로 여러 줄의 텍스트를 생성하고 싶습니다. PHP, GD 및 Freetype을 사용하여 어떻게 수행 할 수 있습니까? 아래는 단선 텍스트 이미지를 생성하는 데 사용하는 코드입니다.PHP에서 텍스트에서 IMage 만들기 - 어떻게 여러 줄을 만들 수 있습니까?
$textval = 'This is some text to be an image';
$textcolor = '666666';
$font="arial.ttf";
$size = 9;
$padding= 1;
$bgcolor= "ffffff";
$transparent = 0;
$antialias = 0;
$fontfile = $fontpath.$font;
$box= imageftbbox($size, 0, $fontfile, $textval, array());
$boxwidth= $box[4];
$boxheight= abs($box[3]) + abs($box[5]);
$width= $boxwidth + ($padding*2) + 1;
$height= $boxheight + ($padding) + 0;
$textx= $padding;
$texty= ($boxheight - abs($box[3])) + $padding;
// create the image
$png= imagecreate($width, $height);
$color = str_replace("#","",$bgcolor);
$red = hexdec(substr($bgcolor,0,2));
$green = hexdec(substr($bgcolor,2,2));
$blue = hexdec(substr($bgcolor,4,2));
$bg = imagecolorallocate($png, $red, $green, $blue);
$color = str_replace("#","",$textcolor);
$red = hexdec(substr($textcolor,0,2));
$green = hexdec(substr($textcolor,2,2));
$blue = hexdec(substr($textcolor,4,2));
$tx = imagecolorallocate($png, $red, $green, $blue);
imagettftext($png, $size, 0, $textx, $texty, $tx, $fontfile, $textval);
header("content-type: image/jpeg");
imagejpeg($png);
imagedestroy($png);
exit;
나는 \ n 그러나 그것은 :( – Ali
안녕 같이 어떤 이유로 그것은 또한 당신이 날 어떻게 정의 이미지 배경을 사용하는 데 도움이 될 수는 \ n을 인쇄 할를 사용하여 시도, 이 함수를 사용하여 보안 문자를 만들려고합니다. – rkaartikeyan