php imagick注释抗锯齿

时间:2012-11-14 20:57:17

标签: php imagick antialiasing

我有一个网络摄像头,想要为图像添加一些注释,但抗锯齿效果很奇怪。我会试着解释一下:

我的图像是这样的:Source image

然后我添加半透明矩形并在其上放置文字:

        //  add background black rectangle
        $draw->setFillColor('black'); 
        $draw->setFillOpacity(0.5);
        $draw->rectangle( 0, 10, $cam['width'], 70 );    // Draw the rectangle 
        //  add lead text
        $draw->setFont('ARIALBD.TTF');
        $draw->setFontSize(14);
        $draw->setFillColor('white');
        $draw->annotation(20, 35, $cam['text']);
        //  add timestamp
        $draw->setFont('ARIAL.TTF');
        $draw->setFontSize(12);
        $draw->setFillColor(new ImagickPixel('#f3ac01'));
        $draw->annotation(20, 50, date("Y-m-d H:i:s"));
        $img->drawImage($draw); 

得到这样的东西:

Adding text

嗯,但是时间戳看起来很难看(看几分钟/秒)。试图禁用抗锯齿:

$draw->setTextAntialias(false);

现在它看起来仍然很难看(看几小时),但现在它有锋利的边缘:

antialiasing turned off

如何通过智能抗锯齿获得结果(我知道PS使用自己的抗锯齿功能,但IMagickDraw会产生真正糟糕的结果):

Want this

2 个答案:

答案 0 :(得分:1)

对我来说,它看起来更像保存时整个图像的压缩级别比抗锯齿,看看setCompressionQuality,并调整压缩质量,直到你避免"模糊"你有照片。

答案 1 :(得分:1)

首先尝试不同的字体。以下是open sansanother link)字体的示例。 enter image description here