平滑文本ImagickDraw?

时间:2015-01-25 23:12:26

标签: php imagemagick image-manipulation imagick

如何在图片中制作文字?

Anti-aliased text

我没有得到消除锯齿的文字:

Without anti-aliasing

如何制作与第一张图片相同的平滑效果?

我的代码:

$body = 'Company Name';
$pointsize = 10*1.4; //PT to pointsize
$fill = '000000';
$width = 170;

$canvas = new Imagick();
$draw = new ImagickDraw();
$color = new ImagickPixel($fill);

$draw->setFont('fonts/Arial/Arial.ttf');
$draw->setFontSize($pointsize);
$draw->setFillColor($color);
$draw->setStrokeAntialias(true);
$draw->setTextAntialias(true);

$data = $canvas->queryFontMetrics($draw, $body);
$draw->annotation(0, $data['ascender'], $body);
$draw->annotation(0, $data['ascender'], $body);

$canvas->newImage($width, $data['textHeight'], 'none');
$canvas->drawImage($draw);

$canvas->setImageFormat('png');

header('Content-Type: image/png');
echo $canvas->getImageBlob();

0 个答案:

没有答案