텍스트 색상이 테두리 색상과 다른 여러 색상의 텍스트가있는 PHP GD 라이브러리를 사용하여 텍스트에 테두리를 지정하려면 어떻게해야합니까?PHP GD 라이브러리의 테두리를 지정하는 방법
당신은 참조 할 수 있습니다으로 : 추가
텍스트 색상이 테두리 색상과 다른 여러 색상의 텍스트가있는 PHP GD 라이브러리를 사용하여 텍스트에 테두리를 지정하려면 어떻게해야합니까?PHP GD 라이브러리의 테두리를 지정하는 방법
당신은 참조 할 수 있습니다으로 : 추가
// http://www.johnciacia.com/2010/01/04/using-php-and-gd-to-add-border-to-text/
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);
}
$font_color = imagecolorallocate($im, 255, 255, 255);
$stroke_color = imagecolorallocate($im, 0, 0, 0);
imagettfstroketext($im, 60, 10, 300, 130, $font_color, $stroke_color, "wqy- microhei.ttc", "简体繁體", 2);
를 사용하여 다음과 같은 기능이 국경
당신은 당신이 할 수 여기에 예를 출력 http://wmh.github.io/hunbook/examples/gd-imagettftext.html
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);
}
잘 작동합니다. 감사합니다. –
GD 라이브러리에서 약간의 혼란을 겪고 있습니다. –
을 확인할 수 있습니다 텍스트 stil/gd-text
클래스 라이브러리를 사용하십시오. 코드 예제 :
<?php
require __DIR__.'/../vendor/autoload.php';
use GDText\Box;
use GDText\Color;
$im = imagecreatetruecolor(500, 500);
$backgroundColor = imagecolorallocate($im, 0, 18, 64);
imagefill($im, 0, 0, $backgroundColor);
$box = new Box($im);
$box->setFontFace(__DIR__.'/Elevant bold.ttf'); // http://www.dafont.com/elevant-by-pelash.font
$box->setFontSize(150);
$box->setFontColor(new Color(255, 255, 255));
$box->setBox(20, 20, 460, 460);
$box->setTextAlign('center', 'center');
$box->setStrokeColor(new Color(255, 75, 140)); // Set stroke color
$box->setStrokeSize(3); // Stroke size in pixels
$box->draw("Elevant"); // Text to draw
header("Content-type: image/png;");
imagepng($im, null, 9, PNG_ALL_FILTERS);
데모 :
는 무엇을 시도했다 우리에게 보여주십시오. – zessx