我一直在尝试使用PHP中的以下代码模糊一些文本:
$image = imagecreate(150,25);
$background = ImageColorAllocate($image, 255, 255, 255);
$foreground = ImageColorAllocate($image, 0, 0, 0);
ImageColorTransparent($image, $background);
ImageInterlace($image, false);
ImageTTFText($image, 20, 0, 0, 20, $foreground, "font.ttf", "some text");
$gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
imageconvolution($image, $gaussian, 16, 0);
imagePNG($image)
然而,图像不会模糊,只会降低分辨率,变得颗粒状...... Demo here..
答案 0 :(得分:2)
删除ImageColorTransparent($image, $background);
以查看效果
示例
$image = imagecreate(150,25);
$background = ImageColorAllocate($image, 255, 255, 255);
$foreground = ImageColorAllocate($image, 0, 0, 0);
ImageInterlace($image, false);
ImageTTFText($image, 20, 0, 0, 20, $foreground, "verdana.ttf", "some text");
$gaussian = array(array(1.0,2.0,1.0),array(2.0,4.0,2.0),array(1.0,2.0,1.0));
imageconvolution($image, $gaussian, 16, 0);
header('Content-Type: image/png');
imagepng($image, null, 9);
输出
^ Before ^ ^ After ^